1. Apr 26, 2024
  2. Apr 25, 2024
  3. Apr 24, 2024
  4. Apr 23, 2024
  5. Apr 22, 2024
  6. Apr 20, 2024
    • Ankan's avatar
      Allow privileged virtual bond in Staking pallet (#3889) · e504c41a
      Ankan authored
      This is the first PR in preparation for
      https://github.com/paritytech/polkadot-sdk/issues/454.
      
      ## Follow ups:
      - https://github.com/paritytech/polkadot-sdk/pull/3904.
      - https://github.com/paritytech/polkadot-sdk/pull/3905.
      
      Overall changes are documented here (lot more visual 😍):
      https://hackmd.io/@ak0n/454-np-governance
      
      [Maybe followup](https://github.com/paritytech/polkadot-sdk/issues/4217)
      with migration of storage item `VirtualStakers` as a bool or enum in
      `Ledger`.
      
      ## Context
      We want to achieve a way for a user (`Delegator`) to delegate their
      funds to another account (`Agent`). Delegate implies the funds are
      locked in delegator account itself. Agent can act on behalf of delegator
      to stake directly on Staking pallet.
      
      The delegation feature is added to Staking via another pallet
      `delegated-staking` worked on
      [here](https://github.com/paritytech/polkadot-sdk/pull/3904).
      
      ## Introduces:
      ### StakingUnchecked Trait
      As the name implies, this trait allows unchecked (non-locked) mutation
      of staking ledger. These apis are only meant to be used by other pallets
      in the runtime and should not be exposed directly to user code path.
      Also related: https://github.com/paritytech/polkadot-sdk/issues/3888.
      
      ### Virtual Bond
      Allows other pallets to stake via staking pallet while managing the
      locks on these accounts themselves. Introduces another storage
      `VirtualStakers` that whitelist these accounts.
      
      We also restrict virtual stakers to set reward account as themselves.
      Since the account has no locks, we cannot support compounding of
      rewards. Conservatively, we require them to set a separate account
      different from the staker. Since these are code managed, it should be
      easy for another pallet to redistribute reward and rebond them.
      
      ### Slashes
      Since there is no actual lock maintained by staking-pallet for virtual
      stakers, this pallet does not apply any slashes. It is then important
      for pallets managing virtual stakers to listen to slashing events and
      apply necessary slashes.
      e504c41a
  7. Apr 19, 2024
  8. Apr 18, 2024
  9. Apr 17, 2024
    • Muharem Ismailov's avatar
      Asset Conversion: Pool Touch Call (#3251) · 305d311d
      Muharem Ismailov authored
      Introduce `touch` call designed to address operational prerequisites
      before providing liquidity to a pool.
      
      This function ensures that essential requirements, such as the presence
      of the pool's accounts, are fulfilled. It is particularly beneficial in
      scenarios where a pool creator removes the pool's accounts without
      providing liquidity.
      
      ---------
      
      Co-authored-by: command-bot <>
      305d311d
    • Oliver Tale-Yazdi's avatar
      Fix nostd build of several crates (#4060) · 7a2c9d4a
      Oliver Tale-Yazdi authored
      Preparation for https://github.com/paritytech/polkadot-sdk/pull/3935
      
      Changes:
      - Add some `default-features = false` for the case that a crate and that
      dependency both support nostd builds.
      - Shuffle files around of some benchmarking-only crates. These
      conditionally disabled the `cfg_attr` for nostd and pulled in libstd.
      Example [here](https://github.com/ggwpez/zepter/pull/95
      
      ). The actual
      logic is moved into a `inner.rs` to preserve nostd capability of the
      crate in case the benchmarking feature is disabled.
      - Add some `use sp_std::vec` where needed.
      - Remove some `optional = true` in cases where it was not optional.
      - Removed one superfluous `cfg_attr(not(feature = "std"), no_std..`.
      
      All in all this should be logical no-op.
      
      ---------
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      7a2c9d4a
    • Muharem Ismailov's avatar
      Asset Conversion: Pool Account ID derivation with additional Pallet ID seed (#3250) · 4e10d3b0
      Muharem Ismailov authored
      Introduce `PalletId` as an additional seed parameter for pool's account
      id derivation.
      
      The PR also introduces the `pallet_asset_conversion_ops` pallet with a
      call to migrate a given pool to thew new account. Additionally
      `fungibles::lifetime::ResetTeam` and `fungible::lifetime::Refund`
      traits, to facilitate the migration of pools.
      
      ---------
      
      Co-authored-by: command-bot <>
      4e10d3b0
    • 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
  10. Apr 16, 2024
  11. Apr 15, 2024
    • Shawn Tabrizi's avatar
      Update pr_3970.prdoc · d0027d15
      Shawn Tabrizi authored
      d0027d15
    • Shawn Tabrizi's avatar
      Create pr_3970.prdoc · 64ceef4c
      Shawn Tabrizi authored
      64ceef4c
    • thiolliere's avatar
      pallet assets: Fix errors (#4118) · a8f4f4f0
      thiolliere authored
      `LiveAsset` is an error to be returned when an asset is not supposed to
      be live.
      And `AssetNotLive` is an error to be returned when an asset is supposed
      to be live, I don't think frozen qualifies as live.
      a8f4f4f0
    • Bastian Köcher's avatar
    • Alexandru Gheorghe's avatar
      Prevent accidental change of network-key for active authorities (#3852) · 2bc4ed11
      Alexandru Gheorghe authored
      As discovered during investigation of
      https://github.com/paritytech/polkadot-sdk/issues/3314 and
      https://github.com/paritytech/polkadot-sdk/issues/3673 there are active
      validators which accidentally might change their network key during
      restart, that's not a safe operation when you are in the active set
      because of distributed nature of DHT, so the old records would still
      exist in the network until they expire 36h, so unless they have a good
      reason validators should avoid changing their key when they restart
      their nodes.
      
      There is an effort in parallel to improve this situation
      https://github.com/paritytech/polkadot-sdk/pull/3786
      
      , but those changes
      are way more intrusive and will need more rigorous testing, additionally
      they will reduce the time to less than 36h, but the propagation won't be
      instant anyway, so not changing your network during restart should be
      the safest way to run your node, unless you have a really good reason to
      change it.
      
      ## Proposal
      1. Do not auto-generate the network if the network file does not exist
      in the provided path. Nodes where the key file does not exist will get
      the following error:
      ```
      Error: 
         0: Starting an authorithy without network key in /home/alexggh/.local/share/polkadot/chains/ksmcc3/network/secret_ed25519.
            
             This is not a safe operation because the old identity still lives in the dht for 36 hours.
            
             Because of it your node might suffer from not being properly connected to other nodes for validation purposes.
            
             If it is the first time running your node you could use one of the following methods.
            
             1. Pass --unsafe-force-node-key-generation and make sure you remove it for subsequent node restarts
            
             2. Separetly generate the key with: polkadot key generate-node-key --file <YOUR_PATH_TO_NODE_KEY>
      ```
      
      2. Add an explicit parameters for nodes that do want to change their
      network despite the warnings or if they run the node for the first time.
      `--unsafe-force-node-key-generation`
      
      3. For `polkadot key generate-node-key` add two new mutually exclusive
      parameters `base_path` and `default_base_path` to help with the key
      generation in the same path the polkadot main command would expect it.
       
      4. Modify the installation scripts to auto-generate a key in default
      path if one was not present already there, this should help with making
      the executable work out of the box after an instalation.
      
      ## Notes
      
      Nodes that do not have already the key persisted will fail to start
      after this change, however I do consider that better than the current
      situation where they start but they silently hide that they might not be
      properly connected to their peers.
      
      ## TODO
      - [x] Make sure only nodes that are authorities on producation chains
      will be affected by this restrictions.
      - [x] Proper PRDOC, to make sure node operators are aware this is
      coming.
      
      ---------
      
      Signed-off-by: default avatarAlexandru Gheorghe <[email protected]>
      Co-authored-by: default avatarDmitry Markin <[email protected]>
      Co-authored-by: default avatars0me0ne-unkn0wn <[email protected]>
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      2bc4ed11
  12. Apr 13, 2024
  13. Apr 12, 2024
    • Branislav Kontur's avatar
      Remove `xcm::v3` from `assets-common` nits (#4037) · 5601f286
      Branislav Kontur authored
      This PR mainly removes `xcm::v3` stuff from `assets-common` to make it
      more generic and facilitate the transition to newer XCM versions. Some
      of the implementations here used hard-coded `xcm::v3::Location`, but now
      it's up to the runtime to configure according to its needs.
      
      Additional/consequent changes:
      - `penpal` runtime uses now `xcm::latest::Location` for `pallet_assets`
      as `AssetId`, because we don't care about migrations here
      - it pretty much simplify xcm-emulator integration tests, where we don't
      need now a lots of boilerplate conversions:
            ```
            v3::Location::try_from(...).expect("conversion works")`
            ```
      - xcm-emulator tests
      - split macro `impl_assets_helpers_for_parachain` to the
      `impl_assets_helpers_for_parachain` and
      `impl_foreign_assets_helpers_for_parachain` (avoids using hard-coded
      `xcm::v3::Location`)
      5601f286
    • Squirrel's avatar
      Remove redundent logging code (#4059) · b28ba4ae
      Squirrel authored
      
      
      1. The `CustomFmtContext::ContextWithFormatFields` enum arm isn't
      actually used and thus we don't need the enum anymore.
      
      2. We don't do anything with most of the normalized metadata that's
      created by calling `event.normalized_metadata();` - the `target` we can
      get from `event.metadata.target()` and level we can get from
      `event.metadata.level()` - let's just call them direct to simplify
      things. (`event.metadata()` is just a field call under the hood)
      
      Changelog: No functional changes, might run a tad faster with lots of
      logging turned on.
      
      ---------
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      b28ba4ae
    • Adrian Catangiu's avatar
      pallet-xcm: add new extrinsic for asset transfers using explicit XCM transfer types (#3695) · 1e971b8d
      Adrian Catangiu authored
      
      
      # Description
      
      Add `transfer_assets_using()` for transferring assets from local chain
      to destination chain using explicit XCM transfer types such as:
      - `TransferType::LocalReserve`: transfer assets to sovereign account of
      destination chain and forward a notification XCM to `dest` to mint and
      deposit reserve-based assets to `beneficiary`.
      - `TransferType::DestinationReserve`: burn local assets and forward a
      notification to `dest` chain to withdraw the reserve assets from this
      chain's sovereign account and deposit them to `beneficiary`.
      - `TransferType::RemoteReserve(reserve)`: burn local assets, forward XCM
      to `reserve` chain to move reserves from this chain's SA to `dest`
      chain's SA, and forward another XCM to `dest` to mint and deposit
      reserve-based assets to `beneficiary`. Typically the remote `reserve` is
      Asset Hub.
      - `TransferType::Teleport`: burn local assets and forward XCM to `dest`
      chain to mint/teleport assets and deposit them to `beneficiary`.
      
      By default, an asset's reserve is its origin chain. But sometimes we may
      want to explicitly use another chain as reserve (as long as allowed by
      runtime `IsReserve` filter).
      
      This is very helpful for transferring assets with multiple configured
      reserves (such as Asset Hub ForeignAssets), when the transfer strictly
      depends on the used reserve.
      
      E.g. For transferring Foreign Assets over a bridge, Asset Hub must be
      used as the reserve location.
      
      # Example usage scenarios
      
      ## Transfer bridged ethereum ERC20-tokenX between ecosystem parachains.
      
      ERC20-tokenX is registered on AssetHub as a ForeignAsset by the
      Polkadot<>Ethereum bridge (Snowbridge). Its asset_id is something like
      `(parents:2, (GlobalConsensus(Ethereum), Address(tokenX_contract)))`.
      Its _original_ reserve is Ethereum (only we can't use Ethereum as a
      reserve in local transfers); but, since tokenX is also registered on
      AssetHub as a ForeignAsset, we can use AssetHub as a reserve.
      
      With this PR we can transfer tokenX from ParaA to ParaB while using
      AssetHub as a reserve.
      
      ## Transfer AssetHub ForeignAssets between parachains
      
      AssetA created on ParaA but also registered as foreign asset on Asset
      Hub. Can use AssetHub as a reserve.
      
      And all of the above can be done while still controlling transfer type
      for `fees` so mixing assets in same transfer is supported.
      
      # Tests
      
      Added integration tests for showcasing:
      - transferring local (not bridged) assets from parachain over bridge
      using local Asset Hub reserve,
      - transferring foreign assets from parachain to Asset Hub,
      - transferring foreign assets from Asset Hub to parachain,
      - transferring foreign assets from parachain to parachain using local
      Asset Hub reserve.
      
      ---------
      
      Co-authored-by: default avatarBranislav Kontur <[email protected]>
      Co-authored-by: command-bot <>
      1e971b8d
    • Andrei Sandu's avatar
      Runtime API: introduce `candidates_pending_availability` (#4027) · 2dfe5f74
      Andrei Sandu authored
      Fixes https://github.com/paritytech/polkadot-sdk/issues/3576
      
      
      
      Required by elastic scaling collators.
      Deprecates old API: `candidate_pending_availability`.
      
      TODO:
      - [x] PRDoc
      
      ---------
      
      Signed-off-by: default avatarAndrei Sandu <[email protected]>
      2dfe5f74
    • Xiliang Chen's avatar
      establish_channel_with_system (#3721) · b1db5f3a
      Xiliang Chen authored
      Implements https://github.com/polkadot-fellows/RFCs/issues/82
      
      
      Allow any parachain to have bidirectional channel with any system
      parachains
      
      Looking for initial feedbacks before continue finish it
      
      TODOs:
      - [x] docs
      - [x] benchmarks
      - [x] tests
      
      ---------
      
      Co-authored-by: default avatarjoe petrowski <[email protected]>
      Co-authored-by: default avatarAdrian Catangiu <[email protected]>
      b1db5f3a