1. Apr 23, 2024
  2. Apr 17, 2024
    • Sergej Sakac's avatar
      XCM coretime region transfers (#3455) · e6f3106d
      Sergej Sakac authored
      This PR introduces changes enabling the transfer of coretime regions via
      XCM.
      
      TL;DR: There are two primary issues that are resolved in this PR:
      
      1. The `mint` and `burn` functions were not implemented for coretime
      regions. These operations are essential for moving assets to and from
      the XCM holding register.
      2. The transfer of non-fungible assets through XCM was previously
      disallowed. This was due to incorrectly benchmarking non-fungible asset
      transfers via XCM, which led to assigning it a weight of `Weight::Max`,
      effectively preventing its execution.
      
      ### `mint_into` and `burn` implementation
      
      This PR addresses the issue with cross-chain transferring regions back
      to the Coretime chain. Remote reserve transfers are performed by
      withdrawing and depositing the asset to and from the holding registry.
      This requires the asset to support burning and minting functionality.
      
      This PR adds burning and minting; however, they work a bit differently
      than usual so that the associated region record is not lost when
      burning. Instead of removing all the data, burning will set the owner of
      the region to `None`, and when minting it back, it will set it to an
      actual value. So, when cross-chain transferring, withdrawing into the
      registry will remove the region from its original owner, and when
      depositing it from the registry, it will set its owner to another
      account
      
      This was originally implemented in this PR: #3455, however we decided to
      move all of it to this single PR
      (https://github.com/paritytech/polkadot-sdk/pull/3455#discussion_r1547324892)
      
      ### Fixes made in this PR
      
      - Update the `XcmReserveTransferFilter` on coretime chain since it is
      meant as a reserve chain for coretime regions.
      - Update the XCM benchmark to use `AssetTransactor` instead of assuming
      `pallet-balances` for fungible transfers.
      - Update the XCM benchmark to properly measure weight consumption for
      nonfungible reserve asset transfers. ATM reserve transfers via the
      extrinsic do not work since the weight for it is set to `Weight::max()`.
      
      Closes: https://github.com/paritytech/polkadot-sdk/issues/865
      
      
      
      ---------
      
      Co-authored-by: default avatarBranislav Kontur <[email protected]>
      Co-authored-by: default avatarFrancisco Aguirre <[email protected]>
      Co-authored-by: default avatarDónal Murray <[email protected]>
      e6f3106d
  3. Apr 16, 2024
  4. Apr 15, 2024
  5. Apr 12, 2024
  6. Apr 10, 2024
  7. Apr 05, 2024
  8. Mar 26, 2024
    • Tsvetomir Dimitrov's avatar
      Migrate parachain swaps to Coretime (#3714) · 90234543
      Tsvetomir Dimitrov authored
      This PR notifies broker pallet for any parachain slot swaps performed on
      the relay chain. This is achieved by registering an `OnSwap` for the the
      `coretime` pallet. The hook sends XCM message to the broker chain and
      invokes a new extrinsic `swap_leases` which updates `Leases` storage
      item (which keeps the legacy parachain leases).
      
      I made two assumptions in this PR:
      1.
      [`Leases`](https://github.com/paritytech/polkadot-sdk/blob/4987d7982461e2e5ffe219cdf71ec697284cea7c/substrate/frame/broker/src/lib.rs#L120)
      in `broker` pallet and
      [`Leases`](https://github.com/paritytech/polkadot-sdk/blob/4987d7982461e2e5ffe219cdf71ec697284cea7c/polkadot/runtime/common/src/slots/mod.rs#L118)
      in `slots` pallet are in sync.
      2. `swap_leases` extrinsic from `broker` pallet can be triggered only by
      root or by the XCM message from the relay chain. If not - the extrinsic
      will generate an error and do nothing.
      
      As a side effect from the changes `OnSwap` trait is moved from
      runtime/common/traits.rs to runtime/parachains. Otherwise it is not
      accessible from `broker` pallet.
      
      Closes https://github.com/paritytech/polkadot-sdk/issues/3552
      
      
      
      TODOs:
      
      - [x] Weights
      - [x] Tests
      
      ---------
      
      Co-authored-by: command-bot <>
      Co-authored-by: default avatareskimor <[email protected]>
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      90234543
    • Dcompoze's avatar
      Fix spelling mistakes across the whole repository (#3808) · 002d9260
      Dcompoze authored
      **Update:** Pushed additional changes based on the review comments.
      
      **This pull request fixes various spelling mistakes in this
      repository.**
      
      Most of the changes are contained in the first **3** commits:
      
      - `Fix spelling mistakes in comments and docs`
      
      - `Fix spelling mistakes in test names`
      
      - `Fix spelling mistakes in error messages, panic messages, logs and
      tracing`
      
      Other source code spelling mistakes are separated into individual
      commits for easier reviewing:
      
      - `Fix the spelling of 'authority'`
      
      - `Fix the spelling of 'REASONABLE_HEADERS_IN_JUSTIFICATION_ANCESTRY'`
      
      - `Fix the spelling of 'prev_enqueud_messages'`
      
      - `Fix the spelling of 'endpoint'`
      
      - `Fix the spelling of 'children'`
      
      - `Fix the spelling of 'PenpalSiblingSovereignAccount'`
      
      - `Fix the spelling of 'PenpalSudoAccount'`
      
      - `Fix the spelling of 'insufficient'`
      
      - `Fix the spelling of 'PalletXcmExtrinsicsBenchmark'`
      
      - `Fix the spelling of 'subtracted'`
      
      - `Fix the spelling of 'CandidatePendingAvailability'`
      
      - `Fix the spelling of 'exclusive'`
      
      - `Fix the spelling of 'until'`
      
      - `Fix the spelling of 'discriminator'`
      
      - `Fix the spelling of 'nonexistent'`
      
      - `Fix the spelling of 'subsystem'`
      
      - `Fix the spelling of 'indices'`
      
      - `Fix the spelling of 'committed'`
      
      - `Fix the spelling of 'topology'`
      
      - `Fix the spelling of 'response'`
      
      - `Fix the spelling of 'beneficiary'`
      
      - `Fix the spelling of 'formatted'`
      
      - `Fix the spelling of 'UNKNOWN_PROOF_REQUEST'`
      
      - `Fix the spelling of 'succeeded'`
      
      - `Fix the spelling of 'reopened'`
      
      - `Fix the spelling of 'proposer'`
      
      - `Fix the spelling of 'InstantiationNonce'`
      
      - `Fix the spelling of 'depositor'`
      
      - `Fix the spelling of 'expiration'`
      
      - `Fix the spelling of 'phantom'`
      
      - `Fix the spelling of 'AggregatedKeyValue'`
      
      - `Fix the spelling of 'randomness'`
      
      - `Fix the spelling of 'defendant'`
      
      - `Fix the spelling of 'AquaticMammal'`
      
      - `Fix the spelling of 'transactions'`
      
      - `Fix the spelling of 'PassingTracingSubscriber'`
      
      - `Fix the spelling of 'TxSignaturePayload'`
      
      - `Fix the spelling of 'versioning'`
      
      - `Fix the spelling of 'descendant'`
      
      - `Fix the spelling of 'overridden'`
      
      - `Fix the spelling of 'network'`
      
      Let me know if this structure is adequate.
      
      **Note:** The usage of the words `Merkle`, `Merkelize`, `Merklization`,
      `Merkelization`, `Merkleization`, is somewhat inconsistent but I left it
      as it is.
      
      ~~**Note:** In some places the term `Receival` is used to refer to
      message reception, IMO `Reception` is the correct word here, but I left
      it as it is.~~
      
      ~~**Note:** In some places the term `Overlayed` is used instead of the
      more acceptable version `Overlaid` but I also left it as it is.~~
      
      ~~**Note:** In some places the term `Applyable` is used instead of the
      correct version `Applicable` but I also left it as it is.~~
      
      **Note:** Some usage of British vs American english e.g. `judgement` vs
      `judgment`, `initialise` vs `initialize`, `optimise` vs `optimize` etc.
      are both present in different places, but I suppose that's
      understandable given the number of contributors.
      
      ~~**Note:** There is a spelling mistake in `.github/CODEOWNERS` but it
      triggers errors in CI when I make changes to it, so I left it as it
      is.~~
      002d9260
  9. Mar 15, 2024
  10. Mar 13, 2024
  11. Mar 11, 2024
    • Dónal Murray's avatar
      [pallet_broker] Fix `adapt_price` behaviour at zero (#3636) · aa353283
      Dónal Murray authored
      
      
      This fixes the behaviour of `Linear` which is the default implementation
      of the `AdaptPrice` trait in the broker pallet. Previously if cores were
      offered but not sold in only one sale, the price would be set to zero
      and due to the logic being purely multiplicative, the price would stay
      at 0 indefinitely.
      
      This could be further paired with a configurable minimum in the broker
      pallet itself, which will be a future PR.
      
      This affects the Rococo and Westend Coretime chains, but Kusama has a
      different implementation so this isn't required for the Kusama launch. I
      actually thought I opened this a while ago.
      
      ---------
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      aa353283
  12. Mar 04, 2024
    • Gavin Wood's avatar
      FRAME: Create `TransactionExtension` as a replacement for `SignedExtension` (#2280) · fd5f9292
      Gavin Wood authored
      Closes #2160
      
      First part of [Extrinsic
      Horizon](https://github.com/paritytech/polkadot-sdk/issues/2415
      
      )
      
      Introduces a new trait `TransactionExtension` to replace
      `SignedExtension`. Introduce the idea of transactions which obey the
      runtime's extensions and have according Extension data (né Extra data)
      yet do not have hard-coded signatures.
      
      Deprecate the terminology of "Unsigned" when used for
      transactions/extrinsics owing to there now being "proper" unsigned
      transactions which obey the extension framework and "old-style" unsigned
      which do not. Instead we have __*General*__ for the former and
      __*Bare*__ for the latter. (Ultimately, the latter will be phased out as
      a type of transaction, and Bare will only be used for Inherents.)
      
      Types of extrinsic are now therefore:
      - Bare (no hardcoded signature, no Extra data; used to be known as
      "Unsigned")
      - Bare transactions (deprecated): Gossiped, validated with
      `ValidateUnsigned` (deprecated) and the `_bare_compat` bits of
      `TransactionExtension` (deprecated).
        - Inherents: Not gossiped, validated with `ProvideInherent`.
      - Extended (Extra data): Gossiped, validated via `TransactionExtension`.
        - Signed transactions (with a hardcoded signature).
        - General transactions (without a hardcoded signature).
      
      `TransactionExtension` differs from `SignedExtension` because:
      - A signature on the underlying transaction may validly not be present.
      - It may alter the origin during validation.
      - `pre_dispatch` is renamed to `prepare` and need not contain the checks
      present in `validate`.
      - `validate` and `prepare` is passed an `Origin` rather than a
      `AccountId`.
      - `validate` may pass arbitrary information into `prepare` via a new
      user-specifiable type `Val`.
      - `AdditionalSigned`/`additional_signed` is renamed to
      `Implicit`/`implicit`. It is encoded *for the entire transaction* and
      passed in to each extension as a new argument to `validate`. This
      facilitates the ability of extensions to acts as underlying crypto.
      
      There is a new `DispatchTransaction` trait which contains only default
      function impls and is impl'ed for any `TransactionExtension` impler. It
      provides several utility functions which reduce some of the tedium from
      using `TransactionExtension` (indeed, none of its regular functions
      should now need to be called directly).
      
      Three transaction version discriminator ("versions") are now
      permissible:
      - 0b000000100: Bare (used to be called "Unsigned"): contains Signature
      or Extra (extension data). After bare transactions are no longer
      supported, this will strictly identify an Inherents only.
      - 0b100000100: Old-school "Signed" Transaction: contains Signature and
      Extra (extension data).
      - 0b010000100: New-school "General" Transaction: contains Extra
      (extension data), but no Signature.
      
      For the New-school General Transaction, it becomes trivial for authors
      to publish extensions to the mechanism for authorizing an Origin, e.g.
      through new kinds of key-signing schemes, ZK proofs, pallet state,
      mutations over pre-authenticated origins or any combination of the
      above.
      
      ## Code Migration
      
      ### NOW: Getting it to build
      
      Wrap your `SignedExtension`s in `AsTransactionExtension`. This should be
      accompanied by renaming your aggregate type in line with the new
      terminology. E.g. Before:
      
      ```rust
      /// The SignedExtension to the basic transaction logic.
      pub type SignedExtra = (
      	/* snip */
      	MySpecialSignedExtension,
      );
      /// Unchecked extrinsic type as expected by this runtime.
      pub type UncheckedExtrinsic =
      	generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
      ```
      
      After:
      
      ```rust
      /// The extension to the basic transaction logic.
      pub type TxExtension = (
      	/* snip */
      	AsTransactionExtension<MySpecialSignedExtension>,
      );
      /// Unchecked extrinsic type as expected by this runtime.
      pub type UncheckedExtrinsic =
      	generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
      ```
      
      You'll also need to alter any transaction building logic to add a
      `.into()` to make the conversion happen. E.g. Before:
      
      ```rust
      fn construct_extrinsic(
      		/* snip */
      ) -> UncheckedExtrinsic {
      	let extra: SignedExtra = (
      		/* snip */
      		MySpecialSignedExtension::new(/* snip */),
      	);
      	let payload = SignedPayload::new(call.clone(), extra.clone()).unwrap();
      	let signature = payload.using_encoded(|e| sender.sign(e));
      	UncheckedExtrinsic::new_signed(
      		/* snip */
      		Signature::Sr25519(signature),
      		extra,
      	)
      }
      ```
      
      After:
      
      ```rust
      fn construct_extrinsic(
      		/* snip */
      ) -> UncheckedExtrinsic {
      	let tx_ext: TxExtension = (
      		/* snip */
      		MySpecialSignedExtension::new(/* snip */).into(),
      	);
      	let payload = SignedPayload::new(call.clone(), tx_ext.clone()).unwrap();
      	let signature = payload.using_encoded(|e| sender.sign(e));
      	UncheckedExtrinsic::new_signed(
      		/* snip */
      		Signature::Sr25519(signature),
      		tx_ext,
      	)
      }
      ```
      
      ### SOON: Migrating to `TransactionExtension`
      
      Most `SignedExtension`s can be trivially converted to become a
      `TransactionExtension`. There are a few things to know.
      
      - Instead of a single trait like `SignedExtension`, you should now
      implement two traits individually: `TransactionExtensionBase` and
      `TransactionExtension`.
      - Weights are now a thing and must be provided via the new function `fn
      weight`.
      
      #### `TransactionExtensionBase`
      
      This trait takes care of anything which is not dependent on types
      specific to your runtime, most notably `Call`.
      
      - `AdditionalSigned`/`additional_signed` is renamed to
      `Implicit`/`implicit`.
      - Weight must be returned by implementing the `weight` function. If your
      extension is associated with a pallet, you'll probably want to do this
      via the pallet's existing benchmarking infrastructure.
      
      #### `TransactionExtension`
      
      Generally:
      - `pre_dispatch` is now `prepare` and you *should not reexecute the
      `validate` functionality in there*!
      - You don't get an account ID any more; you get an origin instead. If
      you need to presume an account ID, then you can use the trait function
      `AsSystemOriginSigner::as_system_origin_signer`.
      - You get an additional ticket, similar to `Pre`, called `Val`. This
      defines data which is passed from `validate` into `prepare`. This is
      important since you should not be duplicating logic from `validate` to
      `prepare`, you need a way of passing your working from the former into
      the latter. This is it.
      - This trait takes two type parameters: `Call` and `Context`. `Call` is
      the runtime call type which used to be an associated type; you can just
      move it to become a type parameter for your trait impl. `Context` is not
      currently used and you can safely implement over it as an unbounded
      type.
      - There's no `AccountId` associated type any more. Just remove it.
      
      Regarding `validate`:
      - You get three new parameters in `validate`; all can be ignored when
      migrating from `SignedExtension`.
      - `validate` returns a tuple on success; the second item in the tuple is
      the new ticket type `Self::Val` which gets passed in to `prepare`. If
      you use any information extracted during `validate` (off-chain and
      on-chain, non-mutating) in `prepare` (on-chain, mutating) then you can
      pass it through with this. For the tuple's last item, just return the
      `origin` argument.
      
      Regarding `prepare`:
      - This is renamed from `pre_dispatch`, but there is one change:
      - FUNCTIONALITY TO VALIDATE THE TRANSACTION NEED NOT BE DUPLICATED FROM
      `validate`!!
      - (This is different to `SignedExtension` which was required to run the
      same checks in `pre_dispatch` as in `validate`.)
      
      Regarding `post_dispatch`:
      - Since there are no unsigned transactions handled by
      `TransactionExtension`, `Pre` is always defined, so the first parameter
      is `Self::Pre` rather than `Option<Self::Pre>`.
      
      If you make use of `SignedExtension::validate_unsigned` or
      `SignedExtension::pre_dispatch_unsigned`, then:
      - Just use the regular versions of these functions instead.
      - Have your logic execute in the case that the `origin` is `None`.
      - Ensure your transaction creation logic creates a General Transaction
      rather than a Bare Transaction; this means having to include all
      `TransactionExtension`s' data.
      - `ValidateUnsigned` can still be used (for now) if you need to be able
      to construct transactions which contain none of the extension data,
      however these will be phased out in stage 2 of the Transactions Horizon,
      so you should consider moving to an extension-centric design.
      
      ## TODO
      
      - [x] Introduce `CheckSignature` impl of `TransactionExtension` to
      ensure it's possible to have crypto be done wholly in a
      `TransactionExtension`.
      - [x] Deprecate `SignedExtension` and move all uses in codebase to
      `TransactionExtension`.
        - [x] `ChargeTransactionPayment`
        - [x] `DummyExtension`
        - [x] `ChargeAssetTxPayment` (asset-tx-payment)
        - [x] `ChargeAssetTxPayment` (asset-conversion-tx-payment)
        - [x] `CheckWeight`
        - [x] `CheckTxVersion`
        - [x] `CheckSpecVersion`
        - [x] `CheckNonce`
        - [x] `CheckNonZeroSender`
        - [x] `CheckMortality`
        - [x] `CheckGenesis`
        - [x] `CheckOnlySudoAccount`
        - [x] `WatchDummy`
        - [x] `PrevalidateAttests`
        - [x] `GenericSignedExtension`
        - [x] `SignedExtension` (chain-polkadot-bulletin)
        - [x] `RefundSignedExtensionAdapter`
      - [x] Implement `fn weight` across the board.
      - [ ] Go through all pre-existing extensions which assume an account
      signer and explicitly handle the possibility of another kind of origin.
      - [x] `CheckNonce` should probably succeed in the case of a non-account
      origin.
      - [x] `CheckNonZeroSender` should succeed in the case of a non-account
      origin.
      - [x] `ChargeTransactionPayment` and family should fail in the case of a
      non-account origin.
        - [ ] 
      - [x] Fix any broken tests.
      
      ---------
      
      Signed-off-by: default avatargeorgepisaltu <[email protected]>
      Signed-off-by: default avatarAlexandru Vasile <[email protected]>
      Signed-off-by: default avatardependabot[bot] <[email protected]>
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      Signed-off-by: default avatarAlexandru Gheorghe <[email protected]>
      Signed-off-by: default avatarAndrei Sandu <[email protected]>
      Co-authored-by: default avatarNikhil Gupta <[email protected]>
      Co-authored-by: default avatargeorgepisaltu <[email protected]>
      Co-authored-by: default avatarChevdor <[email protected]>
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      Co-authored-by: default avatarMaciej <[email protected]>
      Co-authored-by: default avatarJavier Viola <[email protected]>
      Co-authored-by: default avatarMarcin S. <[email protected]>
      Co-authored-by: default avatarTsvetomir Dimitrov <[email protected]>
      Co-authored-by: default avatarJavier Bullrich <[email protected]>
      Co-authored-by: default avatarKoute <[email protected]>
      Co-authored-by: default avatarAdrian Catangiu <[email protected]>
      Co-authored-by: Vladimir Istyufeev's avatarVladimir Istyufeev <[email protected]>
      Co-authored-by: default avatarRoss Bulat <[email protected]>
      Co-authored-by: default avatarGonçalo Pestana <[email protected]>
      Co-authored-by: default avatarLiam Aharon <[email protected]>
      Co-authored-by: default avatarSvyatoslav Nikolsky <[email protected]>
      Co-authored-by: default avatarAndré Silva <[email protected]>
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: default avatars0me0ne-unkn0wn <[email protected]>
      Co-authored-by: default avatarordian <[email protected]>
      Co-authored-by: default avatarSebastian Kunert <[email protected]>
      Co-authored-by: default avatarAaro Altonen <[email protected]>
      Co-authored-by: default avatarDmitry Markin <[email protected]>
      Co-authored-by: default avatarAlexandru Vasile <[email protected]>
      Co-authored-by: default avatarAlexander Samusev <[email protected]>
      Co-authored-by: default avatarJulian Eager <[email protected]>
      Co-authored-by: default avatarMichal Kucharczyk <[email protected]>
      Co-authored-by: default avatarDavide Galassi <[email protected]>
      Co-authored-by: default avatarDónal Murray <[email protected]>
      Co-authored-by: default avataryjh <[email protected]>
      Co-authored-by: default avatarTom Mi <[email protected]>
      Co-authored-by: default avatardependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
      Co-authored-by: default avatarWill | Paradox | ParaNodes.io <[email protected]>
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      Co-authored-by: default avatarJoshy Orndorff <[email protected]>
      Co-authored-by: default avatarJoshy Orndorff <[email protected]>
      Co-authored-by: default avatarPG Herveou <[email protected]>
      Co-authored-by: default avatarAlexander Theißen <[email protected]>
      Co-authored-by: default avatarKian Paimani <[email protected]>
      Co-authored-by: default avatarJuan Girini <[email protected]>
      Co-authored-by: default avatarbader y <[email protected]>
      Co-authored-by: default avatarJames Wilson <[email protected]>
      Co-authored-by: default avatarjoe petrowski <[email protected]>
      Co-authored-by: default avatarasynchronous rob <[email protected]>
      Co-authored-by: default avatarParth <[email protected]>
      Co-authored-by: default avatarAndrew Jones <[email protected]>
      Co-authored-by: default avatarJonathan Udd <[email protected]>
      Co-authored-by: default avatarSerban Iorga <[email protected]>
      Co-authored-by: default avatarEgor_P <[email protected]>
      Co-authored-by: default avatarBranislav Kontur <[email protected]>
      Co-authored-by: default avatarEvgeny Snitko <[email protected]>
      Co-authored-by: default avatarJust van Stam <[email protected]>
      Co-authored-by: default avatarFrancisco Aguirre <[email protected]>
      Co-authored-by: default avatargupnik <[email protected]>
      Co-authored-by: default avatardzmitry-lahoda <[email protected]>
      Co-authored-by: default avatarzhiqiangxu <[email protected]>
      Co-authored-by: default avatarNazar Mokrynskyi <[email protected]>
      Co-authored-by: default avatarAnwesh <[email protected]>
      Co-authored-by: default avatarcheme <[email protected]>
      Co-authored-by: default avatarSam Johnson <[email protected]>
      Co-authored-by: default avatarkianenigma <[email protected]>
      Co-authored-by: default avatarJegor Sidorenko <[email protected]>
      Co-authored-by: default avatarMuharem <[email protected]>
      Co-authored-by: default avatarjoepetrowski <[email protected]>
      Co-authored-by: default avatarAlexandru Gheorghe <[email protected]>
      Co-authored-by: default avatarGabriel Facco de Arruda <[email protected]>
      Co-authored-by: default avatarSquirrel <[email protected]>
      Co-authored-by: default avatarAndrei Sandu <[email protected]>
      Co-authored-by: default avatargeorgepisaltu <[email protected]>
      Co-authored-by: command-bot <>
      fd5f9292
  13. Feb 16, 2024
  14. Feb 08, 2024
    • Dónal Murray's avatar
      [pallet_broker] Remove leases that have already expired in rotate_sale (#3213) · 2ea6bcf1
      Dónal Murray authored
      Leases can be force set, but since `Leases` is a `StorageValue`, if a
      lease misses its sale rotation in which it should expire, it can never
      be cleared.
      
      This can happen if a lease is added with an `until` timeslice that lies
      in a region whose sale has already started or has passed, even if the
      timeslice itself hasn't passed.
      
      This solves that issue in a minimal way, with all expired leases being
      cleaned up in each sale rotation, not just the ones that are expiring in
      the coming region.
      
      TODO:
      - [x] Write test
      2ea6bcf1
  15. Jan 27, 2024
  16. Dec 29, 2023
    • Sergej Sakac's avatar
      Broker pallet: fix interlacing (#2811) · ae14e6da
      Sergej Sakac authored
      With the current code, when a user interlaces their region, the end
      result will be three regions in the state:
      - the non-interlaced region
      - first part of the interlaced region
      - second part of the interlaced region
      
      The existing implementation retains the non-interlaced region in the
      state, leading to a problematic scenario:
      
      1. User 1 acquires a region from the market.
      2. User 1 then interlaces this region.
      3. Subsequently, User 1 transfers one part of the interlaced regions to
      User 2.
      Despite this transfer, User 1 retains the ability to assign the entire
      original non-interlaced region, which is inconsistent with the fact that
      they no longer own one of the interlaced parts.
      
      This PR resolves the issue by removing the original region, ensuring
      that only the two new interlaced regions remain in the state.
      ae14e6da
  17. Dec 27, 2023
  18. Dec 26, 2023
  19. Dec 21, 2023
  20. Dec 19, 2023
  21. Dec 18, 2023
  22. Dec 08, 2023
  23. Nov 28, 2023
  24. Nov 01, 2023
  25. Sep 18, 2023
    • Sergej Sakac's avatar
      Broker pallet: `RegionDropped` event fix & additional tests (#1609) · f14bf347
      Sergej Sakac authored
      This PR includes the following fix:
      - [x] The `duration` is always set to zero in the `RegionDropped` event.
      This is fixed in this PR.
      
      Also added some additional tests to cover some cases that aren't covered
      :
      - [x] Selling a partitioned region to the instantaneous coretime pool.
      - [x] Partitioning a region after assigning it to a particular task.
      - [x] Interlacing a region after assigning it to a particular task.
      f14bf347
  26. Sep 07, 2023
    • gupnik's avatar
      Adds base benchmark for do_tick in broker pallet (#1235) · 91deee7a
      gupnik authored
      
      
      * Adds base benchmark for do_tick
      
      * ".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime=dev --target_dir=substrate --pallet=pallet_broker
      
      * Update substrate/frame/broker/src/benchmarking.rs
      
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Update substrate/frame/broker/src/benchmarking.rs
      
      * ".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime=dev --target_dir=substrate --pallet=pallet_broker
      
      * Addresses review comment
      
      ---------
      
      Co-authored-by: command-bot <>
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      91deee7a
  27. Sep 06, 2023
  28. Sep 03, 2023
  29. Sep 01, 2023
  30. Aug 24, 2023
    • Gavin Wood's avatar
      Frame: Agile Coretime Broker pallet (RFC-1) (#14568) · 46bd466e
      Gavin Wood authored
      
      
      * Add Broker pallet
      
      * Flesh out CorePart
      
      * Repotting and fleshing out
      
      * more drafting
      
      * process timeslice
      
      * Test Fungibles completed
      
      * Auctions
      
      * Price morphing
      
      * First tests
      
      * Tidying up config/status
      
      * Docs
      
      * Timeslice todying
      
      * More Timeslice tidying
      
      * Tests]
      
      * Repotting.
      
      * Tests
      
      * Tests
      
      * System InstaPool cores and payout
      
      * Better Relay Test framework
      
      * Tests and instapool fixes
      
      * Support NFT interface
      
      * Proper renewals
      
      * Better events, results
      
      * Test transfer
      
      * Renewal test
      
      * Repot some impls and make dispatchables.
      
      * Better weight
      
      * Test migration
      
      * Document events
      
      * Introduce durations
      
      * Core count
      
      * Allow reassignment
      
      * Better naming
      
      * Error docs
      
      * Docs
      
      * Formatting
      
      * Advance notice period is in RC blocks, not timeslices
      
      * Docs
      
      * Formatting
      
      * Docs
      
      * Missing file
      
      * Added some events
      
      * Events for all dispatchables
      
      * Remove benchmark
      
      * Fix
      
      * Adds benchmark for configure and some basic setup
      
      * Adds benchmark for reserve and unreserve
      
      * Adds a couple of more benchmarks
      
      * Docs
      
      * Event
      
      * Fix
      
      * Adds benchmark for purchase
      
      * Dedup
      
      * Add some weight breakdowns
      
      * Repotting
      
      * Adds more benchmarks
      
      * Renaming and one more event
      
      * Sale event
      
      * Better price API and docs
      
      * Avoid possibility of clobbering renewal record
      
      * Avoid possibility of clobbering renewal record
      
      * Fixes a few benchmarks
      
      * Another test
      
      * More tests
      
      * Drop history test
      
      * Rename and CORE_MASK_BITS constant
      
      * Update frame/broker/src/dispatchable_impls.rs
      
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Update frame/broker/src/dispatchable_impls.rs
      
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Update frame/broker/src/dispatchable_impls.rs
      
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Update frame/broker/src/utility_impls.rs
      
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Update frame/broker/src/dispatchable_impls.rs
      
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Update frame/broker/src/mock.rs
      
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Addresses few review comments
      
      * Addresses few review comments
      
      * Addresses few review comments
      
      * Merge
      
      * Merge
      
      * ".git/.scripts/commands/fmt/fmt.sh"
      
      * Integrates broker in kitchensink
      
      * Minor update
      
      * Fixes typo
      
      * Moves balance back to u64
      
      * Fixes kitchensink build
      
      * Fixes worst case for assign
      
      * Adds benchmark for process_core_count
      
      * Adds a couple of more benchmarks
      
      * Adds an assert for partition
      
      * Uses max_timeslices as input in claim_revenue benchmark
      
      * Adds benchmark for drop_renewal
      
      * Adds benchmark for process_core_schedule
      
      * Adds benchmark for process_pool
      
      * Adds assertion for transfer
      
      * Fixes benchmark for broker in kitchensink
      
      * Adds todo for process_revenue benchmark
      
      * Minor update
      
      * Fix for pool revenue history
      
      * remove TODOs
      
      * Fix tests
      
      * Document CoretimeInterface
      
      * rename part to mask
      
      * Fixes
      
      * Grumble
      
      * ".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime=dev --target_dir=substrate --pallet=pallet_broker
      
      * Adds benchmark for drop_history and fixes worst case for claim_revenue
      
      * Adds drop_history in WeightInfo
      
      * ".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime=dev --target_dir=substrate --pallet=pallet_broker
      
      * Minor fix for Quick Benchmark CI
      
      * Fixes
      
      * Docs
      
      * Headers
      
      * Expose a couple of APIs for benchmarking (#14688)
      
      * Expose a couple of APIs for benchmarking
      
      * Adds doc
      
      * Minor fix in CoretimeInterface impl for kitchensik
      
      * Minor
      
      * Cap renewal price
      
      * Adds a few tests
      
      * Adds more tests
      
      * Minor updates
      
      * Adds a test for an edge case
      
      * Fixes feature propagation
      
      * Fixes feature propagation
      
      * Adds doc fix
      
      * Syntax nits
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Reuse Bit assign functions
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Bitwise tests
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * adapt_price: Edge case for sold == target
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Add sanity checking to ConfigRecord
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Add deny(missing_docs) where possible
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * partition: forbid pivot_offset == 0
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Sort features
      
      zepter format features
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Import Zero from new location
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Clippy: remove redundant clone
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * try to fix build
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Fix CI
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      ---------
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: default avatarNikhil Gupta <[email protected]>
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: command-bot <>
      46bd466e