1. Jan 27, 2024
  2. Jan 26, 2024
    • Alexander Theißen's avatar
      contracts: Fix printing the `Schedule` (#3021) · 5e5341da
      Alexander Theißen authored
      Printing the `Schedule` is a useful debugging tool and general sanity
      check. It is much more easy to interpret than the raw weights.
      
      The printing relied on using `println` and hence was only available from
      the native runtime. This is no longer available. This is why in this PR
      we switch to using `log` which works from Wasm.
      
      I made sure that the `WeightDebug` is only derived when
      `runtime-benchmarks` is set so that we don't increase the size of the
      binary.
      
      Some other changes were necessary to make this actually work inside the
      runtime. For example, I needed to remove `format!` and usage of floats.
      
      Please note that this removed the decimal from the number because
      truncating the fraction without using floats would not be easy and would
      require custom code. I think the precision here is sufficient.
      
      This is how the output looks like now:
      ```
      Schedule {
          limits: Limits {
              event_topics: 4,
              globals: 256,
              locals: 1024,
              parameters: 128,
              memory_pages: 16,
              table_size: 4096,
              br_table_size: 256,
              subject_len: 32,
              payload_len: 16384,
              runtime_memory: 134217728,
          },
          instruction_weights: InstructionWeights {
              base: 2565,
              _phantom: PhantomData<kitchensink_runtime::Runtime>,
          },
          host_fn_weights: HostFnWeights {
              caller: 322 ns, 6 bytes,
              is_contract: 28 µs, 2684 bytes,
              code_hash: 29 µs, 2688 bytes,
              own_code_hash: 400 ns, 6 bytes,
              caller_is_origin: 176 ns, 3 bytes,
              caller_is_root: 158 ns, 3 bytes,
              address: 315 ns, 6 bytes,
              gas_left: 355 ns, 6 bytes,
              balance: 1 µs, 6 bytes,
              value_transferred: 314 ns, 6 bytes,
              minimum_balance: 318 ns, 6 bytes,
              block_number: 313 ns, 6 bytes,
              now: 325 ns, 6 bytes,
              weight_to_fee: 1 µs, 14 bytes,
              input: 263 ns, 6 bytes,
              input_per_byte: 989 ps, 0 bytes,
              r#return: 0 ps, 45 bytes,
              return_per_byte: 320 ps, 0 bytes,
              terminate: 1 ms, 5266 bytes,
              random: 1 µs, 10 bytes,
              deposit_event: 1 µs, 10 bytes,
              deposit_event_per_topic: 127 µs, 2508 bytes,
              deposit_event_per_byte: 501 ps, 0 bytes,
              debug_message: 226 ns, 7 bytes,
              debug_message_per_byte: 1 ns, 0 bytes,
              set_storage: 131 µs, 293 bytes,
              set_storage_per_new_byte: 576 ps, 0 bytes,
              set_storage_per_old_byte: 184 ps, 1 bytes,
              set_code_hash: 297 µs, 3090 bytes,
              clear_storage: 131 µs, 289 bytes,
              clear_storage_per_byte: 92 ps, 1 bytes,
              contains_storage: 29 µs, 289 bytes,
              contains_storage_per_byte: 213 ps, 1 bytes,
              get_storage: 29 µs, 297 bytes,
              get_storage_per_byte: 980 ps, 1 bytes,
              take_storage: 131 µs, 297 bytes,
              take_storage_per_byte: 921 ps, 1 bytes,
              transfer: 156 µs, 2520 bytes,
              call: 484 µs, 2721 bytes,
              delegate_call: 406 µs, 2637 bytes,
              call_transfer_surcharge: 607 µs, 5227 bytes,
              call_per_cloned_byte: 970 ps, 0 bytes,
              instantiate: 1 ms, 2731 bytes,
              instantiate_transfer_surcharge: 131 µs, 2549 bytes,
              instantiate_per_input_byte: 1 ns, 0 bytes,
              instantiate_per_salt_byte: 1 ns, 0 bytes,
              hash_sha2_256: 377 ns, 8 bytes,
              hash_sha2_256_per_byte: 1 ns, 0 bytes,
              hash_keccak_256: 767 ns, 8 bytes,
              hash_keccak_256_per_byte: 3 ns, 0 bytes,
              hash_blake2_256: 443 ns, 8 bytes,
              hash_blake2_256_per_byte: 1 ns, 0 bytes,
              hash_blake2_128: 440 ns, 8 bytes,
              hash_blake2_128_per_byte: 1 ns, 0 bytes,
              ecdsa_recover: 45 µs, 77 bytes,
              ecdsa_to_eth_address: 11 µs, 42 bytes,
              sr25519_verify: 41 µs, 112 bytes,
              sr25519_verify_per_byte: 5 ns, 1 bytes,
              reentrance_count: 174 ns, 3 bytes,
              account_reentrance_count: 248 ns, 40 bytes,
              instantiation_nonce: 154 ns, 3 bytes,
              add_delegate_dependency: 131 µs, 2606 bytes,
              remove_delegate_dependency: 130 µs, 2568 bytes,
          },
      }
      ###############################################
      Lazy deletion weight per key: Weight(ref_time: 126109302, proof_size: 70)
      Lazy deletion keys per block: 15859
      ```
      5e5341da
    • Liam Aharon's avatar
    • Oliver Tale-Yazdi's avatar
      Fix Pools 6->7 migration (#2942) · dd45c949
      Oliver Tale-Yazdi authored
      
      
      Fix the Pools `v7` migration.
      
      ---------
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: default avatarBranislav Kontur <[email protected]>
      dd45c949
  3. Jan 24, 2024
  4. Jan 23, 2024
    • Niklas Adolfsson's avatar
      rpc: backpressured RPC server (bump jsonrpsee 0.20) (#1313) · e16ef086
      Niklas Adolfsson authored
      This is a rather big change in jsonrpsee, the major things in this bump
      are:
      - Server backpressure (the subscription impls are modified to deal with
      that)
      - Allow custom error types / return types (remove jsonrpsee::core::Error
      and jsonrpee::core::CallError)
      - Bug fixes (graceful shutdown in particular not used by substrate
      anyway)
         - Less dependencies for the clients in particular
         - Return type requires Clone in method call responses
         - Moved to tokio channels
         - Async subscription API (not used in this PR)
      
      Major changes in this PR:
      - The subscriptions are now bounded and if subscription can't keep up
      with the server it is dropped
      - CLI: add parameter to configure the jsonrpc server bounded message
      buffer (default is 64)
      - Add our own subscription helper to deal with the unbounded streams in
      substrate
      
      The most important things in this PR to review is the added helpers
      functions in `substrate/client/rpc/src/utils.rs` and the rest is pretty
      much chore.
      
      Regarding the "bounded buffer limit" it may cause the server to handle
      the JSON-RPC calls
      slower than before.
      
      The message size limit is bounded by "--rpc-response-size" thus "by
      default 10MB * 64 = 640MB"
      but the subscription message size is not covered by this limit and could
      be capped as well.
      
      Hopefully the last release prior to 1.0, sorry in advance for a big PR
      
      Previous attempt: https://github.com/paritytech/substrate/pull/13992
      
      Resolves https://github.com/paritytech/polkadot-sdk/issues/748, resolves
      https://github.com/paritytech/polkadot-sdk/issues/627
      e16ef086
  5. Jan 22, 2024
  6. Jan 20, 2024
  7. Jan 19, 2024
  8. Jan 18, 2024
  9. Jan 17, 2024
  10. Jan 16, 2024
    • Francisco Aguirre's avatar
      XCMv4 (#1230) · 8428f678
      Francisco Aguirre authored
      
      
      # Note for reviewer
      
      Most changes are just syntax changes necessary for the new version.
      Most important files should be the ones under the `xcm` folder.
      
      # Description 
      
      Added XCMv4.
      
      ## Removed `Multi` prefix
      The following types have been renamed:
      - MultiLocation -> Location
      - MultiAsset -> Asset
      - MultiAssets -> Assets
      - InteriorMultiLocation -> InteriorLocation
      - MultiAssetFilter -> AssetFilter
      - VersionedMultiAsset -> VersionedAsset
      - WildMultiAsset -> WildAsset
      - VersionedMultiLocation -> VersionedLocation
      
      In order to fix a name conflict, the `Assets` in `xcm-executor` were
      renamed to `HoldingAssets`, as they represent assets in holding.
      
      ## Removed `Abstract` asset id
      
      It was not being used anywhere and this simplifies the code.
      
      Now assets are just constructed as follows:
      
      ```rust
      let asset: Asset = (AssetId(Location::new(1, Here)), 100u128).into();
      ```
      
      No need for specifying `Concrete` anymore.
      
      ## Outcome is now a named fields struct
      
      Instead of
      
      ```rust
      pub enum Outcome {
        Complete(Weight),
        Incomplete(Weight, Error),
        Error(Error),
      }
      ```
      
      we now have
      
      ```rust
      pub enum Outcome {
        Complete { used: Weight },
        Incomplete { used: Weight, error: Error },
        Error { error: Error },
      }
      ```
      
      ## Added Reanchorable trait
      
      Now both locations and assets implement this trait, making it easier to
      reanchor both.
      
      ## New syntax for building locations and junctions
      
      Now junctions are built using the following methods:
      
      ```rust
      let location = Location {
          parents: 1,
          interior: [Parachain(1000), PalletInstance(50), GeneralIndex(1984)].into()
      };
      ```
      
      or
      
      ```rust
      let location = Location::new(1, [Parachain(1000), PalletInstance(50), GeneralIndex(1984)]);
      ```
      
      And they are matched like so:
      
      ```rust
      match location.unpack() {
        (1, [Parachain(id)]) => ...
        (0, Here) => ...,
        (1, [_]) => ...,
      }
      ```
      
      This syntax is mandatory in v4, and has been also implemented for v2 and
      v3 for easier migration.
      
      This was needed to make all sizes smaller.
      
      # TODO
      - [x] Scaffold v4
      - [x] Port github.com/paritytech/polkadot/pull/7236
      - [x] Remove `Multi` prefix
      - [x] Remove `Abstract` asset id
      
      ---------
      
      Co-authored-by: command-bot <>
      Co-authored-by: default avatarKeith Yeung <[email protected]>
      8428f678
    • Xavier Lau's avatar
      CI check features (#1708) · 05cfb02b
      Xavier Lau authored
      To resolve issue #1136.
      
      This is a cross verification against zepter.
      
      - [cargo-featalign](https://github.com/hack-ink/cargo-featalign):
      Verifies the proper propagation of all features.
      - [zepter](https://github.com/ggwpez/zepter): Checks for accidentally
      enabled features.
      
      cc @ggwpez
      
       
      
      ---
      Switch to a new branch. Original PR #1537.
      
      ---------
      
      Signed-off-by: default avatarXavier Lau <[email protected]>
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: default avatarChevdor <[email protected]>
      05cfb02b
    • Bastian Köcher's avatar
      Some random fixes (#2936) · 1c2db174
      Bastian Köcher authored
      - Do not disable `std` feature in the integration tests
      - `contracts-fixtures` test should only check for `riscv` build when the
      feature is enabled
      1c2db174
  11. Jan 15, 2024
  12. Jan 13, 2024
  13. Jan 12, 2024
  14. Jan 11, 2024
    • Michal Kucharczyk's avatar
      frame-support: sp-runtime dependency updated (serde) (#2907) · c8112e2c
      Michal Kucharczyk authored
      `frame-support` crate compilation fails (reported by @koute):
      
      ```
      $ cargo check --no-default-features --target=wasm32-unknown-unknown
      
      error[E0277]: the trait bound `GC: Serialize` is not satisfied
          --> substrate/frame/support/src/genesis_builder_helper.rs:32:24
           |
      32   |     serde_json::to_string(&GC::default())
           |     --------------------- ^^^^^^^^^^^^^^ the trait `Serialize` is not implemented for `GC`
           |     |
           |     required by a bound introduced by this call
           |
      note: required by a bound in `serde_json::to_string`
          --> /home/kou/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde_json-1.0.111/src/ser.rs:2209:17
           |
      2207 | pub fn to_string<T>(value: &T) -> Result<String>
           |        --------- required by a bound in this function
      2208 | where
      2209 |     T: ?Sized + Serialize,
           |                 ^^^^^^^^^ required by this bound in `to_string`
      help: consider further restricting this bound
           |
      30   |     GC: BuildGenesisConfig + Default + serde::Serialize,
           |                                      ++++++++++++++++++
      ```
      
      This PR should fix this.
      
      For all runtimes `sp-runtime/serde` feature was likely enabled by this
      (and few other pallets):
      
      https://github.com/paritytech/polkadot-sdk/blob/f2a750ee86e72c9ab677aaf588d0a33ee8446bef/substrate/frame/system/Cargo.toml#L27
      c8112e2c
  15. Jan 10, 2024
  16. Jan 09, 2024