- Apr 17, 2024
-
-
PG Herveou authored
- Moved `substrate/frame/contracts/src/tests/builder.rs` into a pub test_utils module, so we can use that in the `pallet-contracts-mock-network` tests - Refactor xcm tests to use XCM builders, and simplify the use case for xcm-send
-
- Apr 12, 2024
-
-
PG Herveou authored
-
- Apr 02, 2024
-
-
Serban Iorga authored
Working towards migrating the `parity-bridges-common` repo inside `polkadot-sdk`. This PR upgrades some dependencies in order to align them with the versions used in `parity-bridges-common` Related to https://github.com/paritytech/parity-bridges-common/issues/2538
-
- Mar 27, 2024
-
-
Ermal Kaleci authored
This will make it possible to use remaining weight on idle for processing enqueued messages. More context here https://github.com/paritytech/polkadot-sdk/issues/3709 --------- Co-authored-by: Adrian Catangiu <[email protected]>
-
Francisco Aguirre authored
`execute` and `send` try to decode the xcm in the parameters before reaching the filter line. The new extrinsics decode only after the filter line. These should be used instead of the old ones. ## TODO - [x] Tests - [x] Generate weights - [x] Deprecation issue -> https://github.com/paritytech/polkadot-sdk/issues/3771 - [x] PRDoc - [x] Handle error in pallet-contracts This would make writing XCMs in PJS Apps more difficult, but here's the fix for that: https://github.com/polkadot-js/apps/pull/10350. Already deployed! https://polkadot.js.org/apps/#/utilities/xcm Supersedes https://github.com/paritytech/polkadot-sdk/pull/1798/ --------- Co-authored-by: PG Herveou <[email protected]> Co-authored-by: command-bot <> Co-authored-by: Adrian Catangiu <[email protected]>
-
- Mar 19, 2024
-
-
Juan Ignacio Rios authored
Currently the xcm-executor returns an `Unimplemented` error if it receives any HRMP-related instruction. What I propose here, which is what we are currently doing in our forked executor at polimec, is to introduce a trait implemented by the executor which will handle those instructions. This way, if parachains want to keep the default behavior, they just use `()` and it will return unimplemented, but they can also implement their own logic to establish HRMP channels with other chains in an automated fashion, without requiring to go through governance. Our implementation is mentioned in the [polkadot HRMP docs](https://arc.net/l/quote/hduiivbu), and it was suggested to us to submit a PR to add these changes to polkadot-sdk. --------- Co-authored-by: Branislav Kontur <[email protected]> Co-authored-by: command-bot <>
-
- Mar 15, 2024
-
-
gupnik authored
Step in https://github.com/paritytech/polkadot-sdk/issues/171 This PR removes `as [disambiguation_path]` syntax from `derive_impl` usage across the polkadot-sdk as introduced in https://github.com/paritytech/polkadot-sdk/pull/3505
-
- Mar 06, 2024
-
-
Sergej Sakac authored
Closes: #3196 --------- Co-authored-by: Alexander Theißen <[email protected]> Co-authored-by: PG Herveou <[email protected]>
-
- Feb 23, 2024
-
-
PG Herveou authored
Add a `ApiVersion` constant to the pallet-contracts Config to communicate with developers the current state of the host functions exposed by the pallet
-
- Feb 19, 2024
-
-
PG Herveou authored
## Xcm changes: - Fix `pallet_xcm::execute`, move the logic into The `ExecuteController` so it can be shared with anything that implement that trait. - Make `ExecuteController::execute` retursn `DispatchErrorWithPostInfo` instead of `DispatchError`, so that we don't charge the full `max_weight` provided if the execution is incomplete (useful for force_batch or contracts calls) - Fix docstring for `pallet_xcm::execute`, to reflect the changes from #2405 - Update the signature for `ExecuteController::execute`, we don't need to return the `Outcome` anymore since we only care about `Outcome::Complete` ## Contracts changes: - Update host fn `xcm_exexute`, we don't need to write the `Outcome` to the sandbox memory anymore. This was also not charged as well before so it if fixes this too. - One of the issue was that the dry_run of a contract that call `xcm_execute` would exhaust the `gas_limit`. This is because `XcmExecuteController::execute` takes a `max_weight` argument, and since we don't want the user to specify it manually we were passing everything left by pre-charghing `ctx.ext.gas_meter().gas_left()` - To fix it I added a `fn influence_lowest_limit` on the `Token` trait and make it return false for `RuntimeCost::XcmExecute`. - Got rid of the `RuntimeToken` indirection, we can just use `RuntimeCost` directly. --------- Co-authored-by: command-bot <>
-
- Feb 13, 2024
-
-
Branislav Kontur authored
I found out during the cleanup of this deprecation message in the `polkadot-fellows` repository that we deprecated `CurrencyAdapter` without making the recommended changes. ## TODO - [ ] fix `polkadot-fellows` bump to 1.6.0 https://github.com/polkadot-fellows/runtimes/pull/159 --------- Co-authored-by: Francisco Aguirre <[email protected]>
-
- Jan 31, 2024
-
-
Branislav Kontur authored
[frame] `#[pallet::composite_enum]` improved variant count handling + removed `pallet_balances`'s `MaxHolds` config (#2657) I started this investigation/issue based on @liamaharon question [here](https://github.com/paritytech/polkadot-sdk/pull/1801#discussion_r1410452499). ## Problem The `pallet_balances` integrity test should correctly detect that the runtime has correct distinct `HoldReasons` variant count. I assume the same situation exists for RuntimeFreezeReason. It is not a critical problem, if we set `MaxHolds` with a sufficiently large value, everything should be ok. However, in this case, the integrity_test check becomes less useful. **Situation for "any" runtime:** - `HoldReason` enums from different pallets: ```rust /// from pallet_nis #[pallet::composite_enum] pub enum HoldReason { NftReceipt, } /// from pallet_preimage #[pallet::composite_enum] pub enum HoldReason { Preimage, } // from pallet_state-trie-migration #[pallet::composite_enum] pub enum HoldReason { SlashForContinueMigrate, SlashForMigrateCustomTop, SlashForMigrateCustomChild, } ``` - generated `RuntimeHoldReason` enum looks like: ```rust pub enum RuntimeHoldReason { #[codec(index = 32u8)] Preimage(pallet_preimage::HoldReason), #[codec(index = 38u8)] Nis(pallet_nis::HoldReason), #[codec(index = 42u8)] StateTrieMigration(pallet_state_trie_migration::HoldReason), } ``` - composite enum `RuntimeHoldReason` variant count is detected as `3` - we set `type MaxHolds = ConstU32<3>` - `pallet_balances::integrity_test` is ok with `3`(at least 3) However, the real problem can occur in a live runtime where some functionality might stop working. This is due to a total of 5 distinct hold reasons (for pallets with multi-instance support, it is even more), and not all of them can be used because of an incorrect `MaxHolds`, which is deemed acceptable according to the `integrity_test`: ``` // pseudo-code - if we try to call all of these: T::Currency::hold(&pallet_nis::HoldReason::NftReceipt.into(), &nft_owner, deposit)?; T::Currency::hold(&pallet_preimage::HoldReason::Preimage.into(), &nft_owner, deposit)?; T::Currency::hold(&pallet_state_trie_migration::HoldReason::SlashForContinueMigrate.into(), &nft_owner, deposit)?; // With `type MaxHolds = ConstU32<3>` these two will fail T::Currency::hold(&pallet_state_trie_migration::HoldReason::SlashForMigrateCustomTop.into(), &nft_owner, deposit)?; T::Currency::hold(&pallet_state_trie_migration::HoldReason::SlashForMigrateCustomChild.into(), &nft_owner, deposit)?; ``` ## Solutions A macro `#[pallet::*]` expansion is extended of `VariantCount` implementation for the `#[pallet::composite_enum]` enum type. This expansion generates the `VariantCount` implementation for pallets' `HoldReason`, `FreezeReason`, `LockId`, and `SlashReason`. Enum variants must be plain enum values without fields to ensure a deterministic count. The composite runtime enum, `RuntimeHoldReason` and `RuntimeFreezeReason`, now sets `VariantCount::VARIANT_COUNT` as the sum of pallets' enum `VariantCount::VARIANT_COUNT`: ```rust #[frame_support::pallet(dev_mode)] mod module_single_instance { #[pallet::composite_enum] pub enum HoldReason { ModuleSingleInstanceReason1, ModuleSingleInstanceReason2, } ... } #[frame_support::pallet(dev_mode)] mod module_multi_instance { #[pallet::composite_enum] pub enum HoldReason<I: 'static = ()> { ModuleMultiInstanceReason1, ModuleMultiInstanceReason2, ModuleMultiInstanceReason3, } ... } impl self::sp_api_hidden_includes_construct_runtime::hidden_include::traits::VariantCount for RuntimeHoldReason { const VARIANT_COUNT: u32 = 0 + module_single_instance::HoldReason::VARIANT_COUNT + module_multi_instance::HoldReason::<module_multi_instance::Instance1>::VARIANT_COUNT + module_multi_instance::HoldReason::<module_multi_instance::Instance2>::VARIANT_COUNT + module_multi_instance::HoldReason::<module_multi_instance::Instance3>::VARIANT_COUNT; } ``` In addition, `MaxHolds` is removed (as suggested [here](https://github.com/paritytech/polkadot-sdk/pull/2657#discussion_r1443324573)) from `pallet_balances`, and its `Holds` are now bounded to `RuntimeHoldReason::VARIANT_COUNT`. Therefore, there is no need to let the runtime specify `MaxHolds`. ## For reviewers Relevant changes can be found here: - `substrate/frame/support/procedural/src/lib.rs` - `substrate/frame/support/procedural/src/pallet/parse/composite.rs` - `substrate/frame/support/procedural/src/pallet/expand/composite.rs` - `substrate/frame/support/procedural/src/construct_runtime/expand/composite_helper.rs` - `substrate/frame/support/procedural/src/construct_runtime/expand/hold_reason.rs` - `substrate/frame/support/procedural/src/construct_runtime/expand/freeze_reason.rs` - `substrate/frame/support/src/traits/misc.rs` And the rest of the files is just about removed `MaxHolds` from `pallet_balances` ## Next steps Do the same for `MaxFreezes` https://github.com/paritytech/polkadot-sdk/issues/2997. --------- Co-authored-by: command-bot <> Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: Dónal Murray <[email protected]> Co-authored-by: gupnik <[email protected]>
-
- Jan 26, 2024
-
-
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 ```
-
Liam Aharon authored
Related https://github.com/paritytech/polkadot-sdk/issues/3032 --- Using https://github.com/liamaharon/cargo-workspace-version-tools/ `cargo run -- sync --path ../polkadot-sdk` --------- Signed-off-by: Oliver Tale-Yazdi <[email protected]> Co-authored-by: Oliver Tale-Yazdi <[email protected]>
-
- Jan 24, 2024
-
-
Just van Stam authored
Moved from: https://github.com/paritytech/polkadot/pull/6951 closes https://github.com/paritytech/polkadot-sdk/issues/490 - [x] update cumulus --- This PR introduces transactional processing of certain xcm instructions. For the list of instructions checkout https://github.com/paritytech/polkadot-sdk/issues/490. The transactional processing is implemented as an xcm-executor config item. The two implementations in this PR are `FrameTransactionalProcessor` and `()`. The `()` implementation does no transactional processing. Each implementation of the `ProcessTransaction` trait has an `IS_TRANSACTIONAL` const that tells the XCVM if transactional processing is actually implemented. If Transactional processing is implemented, changes to touched registers should also be rolled back to prevent inconsistencies. Note for reviewers: Check out the following safety assumption: https://github.com/paritytech/polkadot-sdk/pull/1222/files#diff-4effad7d8c1c9de19fd27e18661cbf2128c8718f3b2420a27d2f816e0749ea53R30 --------- Co-authored-by: Keith Yeung <[email protected]> Co-authored-by: Francisco Aguirre <[email protected]> Co-authored-by: command-bot <>
-
- Jan 22, 2024
-
-
joe petrowski authored
Clean up all the old syntax. --------- Co-authored-by: command-bot <> Co-authored-by: gupnik <[email protected]> Co-authored-by: Nikhil Gupta <[email protected]> Co-authored-by: Maksym H <[email protected]>
-
- Jan 18, 2024
-
-
Tsvetomir Dimitrov authored
Backport of https://github.com/paritytech/polkadot-sdk/pull/1863 to master Extend candidate sanitation in paras_inherent by removing backing votes from disabled validators. Check https://github.com/paritytech/polkadot-sdk/issues/1592 for more details. This change is related to the disabling strategy implementation (https://github.com/paritytech/polkadot-sdk/pull/2226). --------- Co-authored-by: ordian <[email protected]> Co-authored-by: ordian <[email protected]> Co-authored-by: Maciej <[email protected]>
-
- Jan 16, 2024
-
-
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: Keith Yeung <[email protected]>
-
- Dec 14, 2023
-
-
Francisco Aguirre authored
In the move from the old `Currency` traits to the new `fungible/s` family of traits, we already had the `FungiblesAdapter` and `NonFungiblesAdapter` for multiple fungible and non fungible assets respectively. However, for handling only one fungible asset, we were missing a `FungibleAdapter`, and so used the old `CurrencyAdapter` instead. This PR aims to fill in that gap, and provide the new adapter for more updated examples. I marked the old `CurrencyAdapter` as deprecated as part of this PR, and I'll change it to the new `FungibleAdapter` in a following PR. The two stages are separated so as to not bloat this PR with some name fixes in tests. --------- Co-authored-by: command-bot <>
-
- Dec 13, 2023
-
-
Squirrel authored
We currently use a bit of a hack in `.cargo/config` to make sure that clippy isn't too annoying by specifying the list of lints. There is now a stable way to define lints for a workspace. The only down side is that every crate seems to have to opt into this so there's a *few* files modified in this PR. Dependencies: - [x] PR that upgrades CI to use rust 1.74 is merged. --------- Co-authored-by: joe petrowski <[email protected]> Co-authored-by: Branislav Kontur <[email protected]> Co-authored-by: Liam Aharon <[email protected]>
-
- Dec 01, 2023
-
-
Liam Aharon authored
Using taplo, fixes all our broken and inconsistent toml formatting and adds CI to keep them tidy. If people want we can customise the format rules as described here https://taplo.tamasfe.dev/configuration/formatter-options.html @ggwpez , I suggest zepter is used only for checking features are propagated, and leave formatting for taplo to avoid duplicate work and conflicts. TODO - [x] Use `exclude = [...]` syntax in taplo file to ignore zombienet tests instead of deleting the dir --------- Signed-off-by: Oliver Tale-Yazdi <[email protected]> Co-authored-by: Oliver Tale-Yazdi <[email protected]> Co-authored-by: Bastian Köcher <[email protected]>
-
- Nov 29, 2023
-
-
PG Herveou authored
see #2189 This PR does the following: - Bring the user api functions into a new pallet-contracts-uapi (They are currently defined in ink! [here])(https://github.com/paritytech/ink/blob/master/crates/env/src/engine/on_chain/ext.rs) - Add older api versions and unstable to the user api trait. - Remove pallet-contracts-primitives and bring the types it defined in uapi / pallet-contracts - Add the infrastructure to build fixtures from Rust files and test it works by replacing `dummy.wat` and `call.wat` - Move all the doc from wasm/runtime.rs to pallet-contracts-uapi. This will be done in a follow up: - convert the rest of the test from .wat to rust - bring risc-v uapi up to date with wasm - finalize the uapi host fns, making sure everything is codegen from the source host fns in pallet-contracts --------- Co-authored-by: Alexander Theißen <[email protected]>
-
- Nov 28, 2023
-
-
gupnik authored
Step in https://github.com/paritytech/polkadot-sdk/issues/171 This PR adds `derive_impl` on all `frame_system` config impls for mock runtimes. The overridden configs are maintained as of now to ensure minimal changes. --------- Co-authored-by: Oliver Tale-Yazdi <[email protected]>
-
- Nov 14, 2023
-
-
PG Herveou authored
This PR introduces: - XCM host functions `xcm_send`, `xcm_execute` - An Xcm trait into the config. that proxy these functions to to `pallet_xcm`, or disable their usage by using `()`. - A mock_network and xcm_test files to test the newly added xcm-related functions. --------- Co-authored-by: Keith Yeung <[email protected]> Co-authored-by: Sasha Gryaznov <[email protected]> Co-authored-by: command-bot <> Co-authored-by: Francisco Aguirre <[email protected]> Co-authored-by: Alexander Theißen <[email protected]>
-