Commit Graph

16856 Commits

Author SHA1 Message Date
Oliver Tale-Yazdi 30c58fa22a Deploy pallet-parameters to rococo and fix dynamic_params name expand (#4006)
Changes:
- Add pallet-parameters to Rococo to configure the NIS and preimage
pallet.
- Fix names of expanded dynamic params. Apparently, `to_class_case`
removes suffix `s`, and `Nis` becomes `Ni` 😑. Now using
`to_pascal_case`.

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Alessandro Siniscalchi <asiniscalchi@gmail.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: command-bot <>
2024-04-13 11:20:42 +00:00
Przemek Rzad 1bca825cc2 Use master environment in the synchronize templates workflow (#4114) 2024-04-13 15:00:45 +04:00
Przemek Rzad aa43797437 Use Github Issue Sync to automate issues in Parachain board (#3694)
This workflow will automatically add issues related to async backing to
the Parachain team board, updating a custom "meta" field.

Requested by @the-right-joyce
2024-04-13 09:33:37 +00:00
Bastian Köcher 7c698502d1 sc_network_test: Announce only the highest block (#4111)
Closes: https://github.com/paritytech/polkadot-sdk/issues/4100
2024-04-13 08:40:10 +00:00
Serban Iorga 8220c98008 Fix zombienet-bridges-0001-asset-transfer-works (#4069)
Fixes https://github.com/paritytech/polkadot-sdk/issues/3999

---------

Co-authored-by: Branislav Kontur <bkontur@gmail.com>
2024-04-13 07:04:26 +00:00
Vedhavyas Singareddi 5b513cc0e9 define block hash provider and default impl using frame_system (#4080)
This PR introduces `BlockHashProvider` into `pallet_mmr::Config`
This type is used to get `block_hash` for a given `block_number` rather
than directly using `frame_system::Pallet::block_hash`

The `DefaultBlockHashProvider` uses `frame_system::Pallet::block_hash`
to get the `block_hash`

Closes: #4062
2024-04-12 21:57:05 +00:00
Branislav Kontur 5601f2865b Remove xcm::v3 from assets-common nits (#4037)
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`)
2024-04-12 21:24:09 +00:00
Squirrel b28ba4ae96 Remove redundent logging code (#4059)
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: Bastian Köcher <git@kchr.de>
2024-04-12 21:18:48 +00:00
Przemek Rzad c963dc283a Synchronize templates (#4040)
- Progresses https://github.com/paritytech/polkadot-sdk/issues/3155

### What's inside

A job, that will take each of the three
[templates](https://github.com/paritytech/polkadot-sdk/tree/master/templates),
yank them out of the monorepo workspace, and push to individual
repositories
([1](https://github.com/paritytech/polkadot-sdk-minimal-template),
[2](https://github.com/paritytech/polkadot-sdk-parachain-template),
[3](https://github.com/paritytech/polkadot-sdk-solochain-template)).

In case the build/test does not succeed, a PR such as [this
one](https://github.com/paritytech-stg/polkadot-sdk-solochain-template/pull/2)
gets created instead.

I'm proposing a manual dispatch trigger for now - so we can test and
iterate faster - and change it to fully automatic triggered by releases
later.

The manual trigger looks like this:

<img width="340px"
src="https://github.com/paritytech/polkadot-sdk/assets/12039224/e87e0fda-23a3-4735-9035-af801e8417fc"/>

### How it works

The job replaces dependencies [referenced by
git](https://github.com/paritytech/polkadot-sdk/blob/d733c77ee2d2e8e2d5205c552a5efb2e5b5242c8/templates/minimal/pallets/template/Cargo.toml#L25)
with a reference to released crates using
[psvm](https://github.com/paritytech/psvm).

It creates a new workspace for the template, and adapts what's needed
from the `polkadot-sdk` workspace.

### See the results

The action has been tried out in staging, and the results can be
observed here:

- [minimal
stg](https://github.com/paritytech-stg/polkadot-sdk-minimal-template/)
- [parachain
stg](https://github.com/paritytech-stg/polkadot-sdk-parachain-template/)
- [solochain
stg](https://github.com/paritytech-stg/polkadot-sdk-solochain-template/)

These are based on the `1.9.0` release (using `release-crates-io-v1.9.0`
branch).
2024-04-12 17:24:35 +00:00
wersfeds 480d5d0fea chore: fix some typos (#4095) 2024-04-12 14:32:23 +00:00
Adrian Catangiu 1e971b8d2a pallet-xcm: add new extrinsic for asset transfers using explicit XCM transfer types (#3695)
# 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: Branislav Kontur <bkontur@gmail.com>
Co-authored-by: command-bot <>
2024-04-12 13:53:12 +00:00
Andrei Sandu 2dfe5f745c Runtime API: introduce candidates_pending_availability (#4027)
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: Andrei Sandu <andrei-mihail@parity.io>
2024-04-12 10:50:13 +00:00
Svyatoslav Nikolsky a1cb2a5123 Move bridge extensions to a separate folder (#4096)
As requested in
https://github.com/paritytech/parity-bridges-common/pull/2873#discussion_r1558974215
2024-04-12 10:42:30 +00:00
eskimor a64009ae00 Improve docs of broker pallet (#3980)
Small adjustments which should make understanding what is going on much
easier for future readers.

Initialization is a bit messy, the very least we should do is adding
documentation to make it harder to use wrongly.

I was thinking about calling `request_core_count` right from
`start_sales`, but as explained in the docs, this is not necessarily
what you want.

---------

Co-authored-by: eskimor <eskimor@no-such-url.com>
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Dónal Murray <donal.murray@parity.io>
2024-04-12 10:23:49 +00:00
Xiliang Chen b1db5f3a90 establish_channel_with_system (#3721)
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: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
Co-authored-by: Adrian Catangiu <adrian@parity.io>
2024-04-12 10:14:20 +00:00
Andrei Sandu 13ca339e4a Adjust zombienet test resources and logic (#4032)
One more try to make this test robust from a resource perspective.

---------

Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
Co-authored-by: Javier Viola <javier@parity.io>
2024-04-12 10:08:34 +00:00
PG Herveou 033484c3ba Use defaultConfig for pallet_contracts (#1817) 2024-04-12 09:35:17 +00:00
Liam Aharon 39b1f50f1c Remove deprecated TryRuntime subcommand (#4017)
Completes the removal of `try-runtime-cli` logic from `polkadot-sdk`.
2024-04-11 20:01:16 +00:00
Andrei Eres 25f038aa8e Run subsystem-benchmark without network latency (#4068)
Implements the idea from
https://github.com/paritytech/polkadot-sdk/pull/3899
- Removed latencies
- Number of runs reduced from 50 to 5, according to local runs it's
quite enough
- Network message is always sent in a spawned task, even if latency is
zero. Without it, CPU time sometimes spikes.
- Removed the `testnet` profile because we probably don't need that
debug additions.

After the local tests I can't say that it brings a significant
improvement in the stability of the results. However, I belive it is
worth trying and looking at the results over time.
2024-04-11 16:54:59 +00:00
Alexander Samusev 6ebf491b50 [ci] Divide subsystem-regression-tests into 2 jobs (#4076)
Currently `subsystem-regression-tests` job fails if the first benchmarks
fail and there is no result for the second benchmark. Also dividing the
job makes the pipeline faster (currently it's a longest job)

cc https://github.com/paritytech/ci_cd/issues/969
cc @AndreiEres

---------

Co-authored-by: Andrei Eres <eresav@me.com>
2024-04-11 15:29:00 +00:00
s0me0ne-unkn0wn f13408d57f Enable mainnet system parachains to use async backing-enabled collator (#3630)
This is phase 2 of async backing enablement for the system parachains on
the production networks. ~~It should be merged after
polkadot-fellows/runtimes#228 is enacted. After it is released,~~ all
the system parachain collators should be upgraded, and then we can
proceed with phase 3, which will enable async backing in the runtimes.

UPDATE: Indeed, we don't need to wait for the runtime upgrade enactions.
The lookahead collator handles the transition by itself, so we can
upgrade ASAP.

## Scope of changes

Here, we eliminate the dichotomy of having "generic Aura collators" for
the production system parachains and "lookahead Aura collators" for the
testnet system parachains. Now, all the collators are started as
lookahead ones, preserving the logic of transferring from the shell node
to Aura-enabled collators for the asset hubs. So, indeed, it simplifies
the parachain service logic, which cannot but rejoice.
2024-04-11 14:58:56 +00:00
Oliver Tale-Yazdi 832570545b Fix link check (#4074)
Closes #4041

Changes:
- Increase cache size and reduce retries.
- Ignore Substrate SE links :(
- Fix broken link.

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
2024-04-11 10:55:42 +00:00
Andrei Sandu 9ede4152ef collation-generation: Avoid using para_backing_state if runtime is ancient (#4070)
fixes https://github.com/paritytech/polkadot-sdk/issues/4067

Also add an early bail out for look ahead collator such that we don't
waste time if a CollatorFn is not set.

TODO:
- [x] add test.
- [x] Polkadot System Parachain burn-in.

---------

Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
2024-04-11 10:36:30 +00:00
Andrei Sandu 69cc7f2090 Fix ClaimQueue case of nothing scheduled on session boundary (#4065)
Same issue but about av-cores was fixed in
https://github.com/paritytech/polkadot-sdk/pull/1403

Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
2024-04-11 08:37:12 +00:00
PG Herveou 643aa2be2a Contracts: Remove ED from base deposit (#3536)
- Update internal logic so that the storage_base_deposit does not
include ED
- add v16 migration to update ContractInfo struct with this change

Before:
<img width="820" alt="Screenshot 2024-03-21 at 11 23 29"
src="https://github.com/paritytech/polkadot-sdk/assets/521091/a0a8df0d-e743-42c5-9e16-cf2ec1aa949c">

After:
![Screenshot 2024-03-21 at 11 23
42](https://github.com/paritytech/polkadot-sdk/assets/521091/593235b0-b866-4915-b653-2071d793228b)

---------

Co-authored-by: Cyrill Leutwiler <cyrill@parity.io>
Co-authored-by: command-bot <>
2024-04-10 20:32:53 +00:00
Milos Kriz d21a41f238 Amend chainspecs for people-westend and add IBP bootnodes (#4072)
Dear team, dear @NachoPal @joepetrowski @bkchr @ggwpez,

This is a retry of #3957, after merging master as advised!,

Many thanks!

**_Milos_**

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
2024-04-10 19:31:31 +00:00
PG Herveou 1da8d12dd1 Contracts: Reuse module when validating (#3789)
Reuse wasmi Module when validating.
Prepare the code for 0.32 and the addition of Module::new_unchecked
2024-04-10 18:56:51 +00:00
Alexandru Vasile cd010925e1 net/strategy: Log bad peerId from on_validated_block_announce (#4051)
This tiny PR extends the `on_validated_block_announce` log with the bad
PeerID.
Used to identify if the peerID is malicious by correlating with other
logs (ie peer-set).

While at it, have removed the `\n` from a multiline log, which did not
play well with
[sub-triage-logs](https://github.com/lexnv/sub-triage-logs/tree/master).

cc @paritytech/networking

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Co-authored-by: Bastian Köcher <git@kchr.de>
2024-04-10 15:29:36 +00:00
PG Herveou 0d71753e0e Contracts: Only exec parsed code in benchmarks (#3915)
[Weights
compare](https://weights.tasty.limo/compare?unit=weight&ignore_errors=true&threshold=10&method=asymptotic&repo=polkadot-sdk&old=master&new=pg%2Fbench_tweaks&path_pattern=substrate%2Fframe%2F**%2Fsrc%2Fweights.rs%2Cpolkadot%2Fruntime%2F*%2Fsrc%2Fweights%2F**%2F*.rs%2Cpolkadot%2Fbridges%2Fmodules%2F*%2Fsrc%2Fweights.rs%2Ccumulus%2F**%2Fweights%2F*.rs%2Ccumulus%2F**%2Fweights%2Fxcm%2F*.rs%2Ccumulus%2F**%2Fsrc%2Fweights.rs)

Note: Raw weights change does not mean much here, as this PR reduce the
scope of what is benchmarked, they are therefore decreased by a good
margin. One should instead print the Schedule using

cargo test --features runtime-benchmarks bench_print_schedule --
--nocapture
or following the instructions from the
[README](https://github.com/paritytech/polkadot-sdk/tree/pg/bench_tweaks/substrate/frame/contracts#schedule)
for looking at the Schedule of a specific runtime

---------

Co-authored-by: command-bot <>
2024-04-10 13:05:34 +00:00
Matteo Muraca 92e142555d Removed pallet::getter usage from Polkadot Runtime pallets (#3660)
Part of #3326 

@kianenigma @ggwpez 

polkadot address: 12poSUQPtcF1HUPQGY3zZu2P8emuW9YnsPduA4XG3oCEfJVp

---------

Signed-off-by: Matteo Muraca <mmuraca247@gmail.com>
Co-authored-by: ordian <write@reusable.software>
2024-04-10 08:35:10 +00:00
Bulat Saifullin d96a97526e Convert chainspec to raw (#4057)
The plain `people-kusama` and `coretime-kusama` chainspecs were uploaded
at https://github.com/paritytech/polkadot-sdk/pull/3961. Only binaries
with compatible runtime versions can run with plain chainspec. For
example:

One of the latest master builds fails:

```
docker run paritypr/polkadot-parachain-debug:master-216509db --chain coretime-kusama
...
Error: Service(Client(Storage("wasm call error Other: Exported method GenesisBuilder_get_preset is not found"))
```

Master build from 5 days ago:

```
docker run paritypr/polkadot-parachain-debug:master-68cdb126 --chain coretime-kusama
...
2024-04-08 16:51:02 [Parachain] 🔨 Initializing Genesis block/state (state: 0xc418…889c, header-hash: 0x638c…d050)
2024-04-08 16:51:03 [Relaychain] 🔨 Initializing Genesis block/state (state: 0xb000…ef6b, header-hash: 0xb0a8…dafe)
2024-04-08 16:51:03 [Relaychain] 👴 Loading GRANDPA authority set from genesis on what appears to be first startup.
2024-04-08 16:51:03 [Relaychain] 👶 Creating empty BABE epoch changes on what appears to be first startup.
2024-04-08 16:51:03 [Relaychain] 🏷 Local node identity is: 12D3KooWQEp2uPow3FnngGmy9dYQ3qxY1GkmumS5MqBWEQscwTyy
2024-04-08 16:51:03 [Relaychain] 📦 Highest known block at #0
...
```

## Changes:

1. Rename:
```
coretime-kusama.json -> coretime-kusama-genesis.json
people-kusama.json -> people-kusama-genesis.json
```

2. Generate raw chainspec:

```
docker run --rm -v $(pwd):/dir paritypr/polkadot-parachain-debug:master-68cdb126 build-spec --raw --chain /dir/people-kusama-genesis.json > people-kusama.json 
docker run --rm -v $(pwd):/dir paritypr/polkadot-parachain-debug:master-68cdb126 build-spec --raw --chain /dir/coretime-kusama-genesis.json > coretime-kusama.json
```

## Tests:

New chainspec can run on the latest master build:

```
docker run -it --rm -v $(pwd):/dir paritypr/polkadot-parachain-debug:master-216509db --chain /dir/coretime-kusama.json
...
2024-04-09 16:44:39 [Relaychain] ⚙️ Syncing, target=#22665488 (8 peers), best: #2371 (0x19f8…5f3a), finalized #2048 (0xede6…f879), ⬇ 388.6kiB/s ⬆ 87.0kiB/s
2024-04-09 16:44:39 [Parachain] 💤 Idle (6 peers), best: #0 (0x638c…d050), finalized #0 (0x638c…d050), ⬇ 6.3kiB/s ⬆ 2.8kiB/s
```

Plain chainspec will fail:

```
docker run -it --rm -v $(pwd):/dir paritypr/polkadot-parachain-debug:master-216509db --chain /dir/coretime-kusama-genesis.json
... 
Error: Service(Client(Storage("wasm call error Other: Exported method GenesisBuilder_get_preset is not found")))
```
2024-04-10 07:53:04 +00:00
Serban Iorga b8956fe150 Reapply lost changes 2024-04-10 10:28:37 +02:00
Serban Iorga fb84c4618a Fix chain_spec_as_json_fails_with_invalid_config 2024-04-10 10:28:37 +02:00
Serban Iorga a230a377d1 Leftovers 2024-04-10 10:28:37 +02:00
Serban Iorga 4ad46c8170 diener workspacify 2024-04-10 10:28:37 +02:00
Serban Iorga 6be8898211 Backport changes from polakdot-sdk (#2920)
* Migrate fee payment from `Currency` to `fungible` (#2292)

Part of https://github.com/paritytech/polkadot-sdk/issues/226
Related https://github.com/paritytech/polkadot-sdk/issues/1833

- Deprecate `CurrencyAdapter` and introduce `FungibleAdapter`
- Deprecate `ToStakingPot` and replace usage with `ResolveTo`
- Required creating a new `StakingPotAccountId` struct that implements
`TypedGet` for the staking pot account ID
- Update parachain common utils `DealWithFees`, `ToAuthor` and
`AssetsToBlockAuthor` implementations to use `fungible`
- Update runtime XCM Weight Traders to use `ResolveTo` instead of
`ToStakingPot`
- Update runtime Transaction Payment pallets to use `FungibleAdapter`
instead of `CurrencyAdapter`
- [x] Blocked by https://github.com/paritytech/polkadot-sdk/pull/1296,
needs the `Unbalanced::decrease_balance` fix

(cherry picked from commit bda4e75ac4)

* Upgrade `trie-db` from `0.28.0` to `0.29.0` (#3982)

- What does this PR do?
1. Upgrades `trie-db`'s version to the latest release. This release
includes, among others, an implementation of `DoubleEndedIterator` for
the `TrieDB` struct, allowing to iterate both backwards and forwards
within the leaves of a trie.
2. Upgrades `trie-bench` to `0.39.0` for compatibility.
3. Upgrades `criterion` to `0.5.1` for compatibility.
- Why are these changes needed?
Besides keeping up with the upgrade of `trie-db`, this specifically adds
the functionality of iterating back on the leafs of a trie, with
`sp-trie`. In a project we're currently working on, this comes very
handy to verify a Merkle proof that is the response to a challenge. The
challenge is a random hash that (most likely) will not be an existing
leaf in the trie. So the challenged user, has to provide a Merkle proof
of the previous and next existing leafs in the trie, that surround the
random challenged hash.

Without having DoubleEnded iterators, we're forced to iterate until we
find the first existing leaf, like so:
```rust
        // ************* VERIFIER (RUNTIME) *************
        // Verify proof. This generates a partial trie based on the proof and
        // checks that the root hash matches the `expected_root`.
        let (memdb, root) = proof.to_memory_db(Some(&root)).unwrap();
        let trie = TrieDBBuilder::<LayoutV1<RefHasher>>::new(&memdb, &root).build();

        // Print all leaf node keys and values.
        println!("\nPrinting leaf nodes of partial tree...");
        for key in trie.key_iter().unwrap() {
            if key.is_ok() {
                println!("Leaf node key: {:?}", key.clone().unwrap());

                let val = trie.get(&key.unwrap());

                if val.is_ok() {
                    println!("Leaf node value: {:?}", val.unwrap());
                } else {
                    println!("Leaf node value: None");
                }
            }
        }

        println!("RECONSTRUCTED TRIE {:#?}", trie);

        // Create an iterator over the leaf nodes.
        let mut iter = trie.iter().unwrap();

        // First element with a value should be the previous existing leaf to the challenged hash.
        let mut prev_key = None;
        for element in &mut iter {
            if element.is_ok() {
                let (key, _) = element.unwrap();
                prev_key = Some(key);
                break;
            }
        }
        assert!(prev_key.is_some());

        // Since hashes are `Vec<u8>` ordered in big-endian, we can compare them directly.
        assert!(prev_key.unwrap() <= challenge_hash.to_vec());

        // The next element should exist (meaning there is no other existing leaf between the
        // previous and next leaf) and it should be greater than the challenged hash.
        let next_key = iter.next().unwrap().unwrap().0;
        assert!(next_key >= challenge_hash.to_vec());
```

With DoubleEnded iterators, we can avoid that, like this:
```rust
        // ************* VERIFIER (RUNTIME) *************
        // Verify proof. This generates a partial trie based on the proof and
        // checks that the root hash matches the `expected_root`.
        let (memdb, root) = proof.to_memory_db(Some(&root)).unwrap();
        let trie = TrieDBBuilder::<LayoutV1<RefHasher>>::new(&memdb, &root).build();

        // Print all leaf node keys and values.
        println!("\nPrinting leaf nodes of partial tree...");
        for key in trie.key_iter().unwrap() {
            if key.is_ok() {
                println!("Leaf node key: {:?}", key.clone().unwrap());

                let val = trie.get(&key.unwrap());

                if val.is_ok() {
                    println!("Leaf node value: {:?}", val.unwrap());
                } else {
                    println!("Leaf node value: None");
                }
            }
        }

        // println!("RECONSTRUCTED TRIE {:#?}", trie);
        println!("\nChallenged key: {:?}", challenge_hash);

        // Create an iterator over the leaf nodes.
        let mut double_ended_iter = trie.into_double_ended_iter().unwrap();

        // First element with a value should be the previous existing leaf to the challenged hash.
        double_ended_iter.seek(&challenge_hash.to_vec()).unwrap();
        let next_key = double_ended_iter.next_back().unwrap().unwrap().0;
        let prev_key = double_ended_iter.next_back().unwrap().unwrap().0;

        // Since hashes are `Vec<u8>` ordered in big-endian, we can compare them directly.
        println!("Prev key: {:?}", prev_key);
        assert!(prev_key <= challenge_hash.to_vec());

        println!("Next key: {:?}", next_key);
        assert!(next_key >= challenge_hash.to_vec());
```
- How were these changes implemented and what do they affect?
All that is needed for this functionality to be exposed is changing the
version number of `trie-db` in all the `Cargo.toml`s applicable, and
re-exporting some additional structs from `trie-db` in `sp-trie`.

---------

Co-authored-by: Bastian Köcher <git@kchr.de>
(cherry picked from commit 4e73c0fcd3)

* Update polkadot-sdk refs

* Fix Cargo.lock

---------

Co-authored-by: Liam Aharon <liam.aharon@hotmail.com>
Co-authored-by: Facundo Farall <37149322+ffarall@users.noreply.github.com>
2024-04-10 10:28:37 +02:00
Serban Iorga 3f1a9279a6 ckb-merkle-mountain-range -> 0.5.2 (#2911) 2024-04-10 10:28:37 +02:00
Serban Iorga 8f26000e6a Address migration comments (#2910)
* Use workspace.[authors|edition]

* Add repository.workspace = true

* Upgrade dependencies to the polkadot-sdk versions

* Upgrade async-std version

* Update jsonrpsee version

* cargo update

* use ci-unified image
2024-04-10 10:28:37 +02:00
Svyatoslav Nikolsky 018d6d8d1a Some relayer improvments (#2902)
* added CLI arguments: full WS URI + separate for WS path URI component + additional log

* URI -> URL?

* added TODO

* fmt
2024-04-10 10:28:37 +02:00
dependabot[bot] 30a0338717 Bump tokio from 1.36.0 to 1.37.0
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.36.0 to 1.37.0.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.36.0...tokio-1.37.0)

---
updated-dependencies:
- dependency-name: tokio
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-10 10:28:37 +02:00
dependabot[bot] e489f5f53f Bump scale-info from 2.11.0 to 2.11.1
Bumps [scale-info](https://github.com/paritytech/scale-info) from 2.11.0 to 2.11.1.
- [Release notes](https://github.com/paritytech/scale-info/releases)
- [Changelog](https://github.com/paritytech/scale-info/blob/master/CHANGELOG.md)
- [Commits](https://github.com/paritytech/scale-info/compare/v2.11.0...v2.11.1)

---
updated-dependencies:
- dependency-name: scale-info
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-10 10:28:37 +02:00
Serban Iorga de37ffd531 Fix polkadot-sdk CI failures (#2901)
* taplo

* markdown

* publish = false

* feature propagation
2024-04-10 10:28:37 +02:00
Serban Iorga aeb3438322 Leftover (#2900) 2024-04-10 10:28:37 +02:00
Serban Iorga 1dba7e052d Backport changes from polkadot-sdk (#2899)
* Fix spelling mistakes across the whole repository (#3808)

**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.~~

(cherry picked from commit 002d9260f9)

* Fix

---------

Co-authored-by: Dcompoze <contact@dcsoftware.xyz>
2024-04-10 10:28:37 +02:00
Serban Iorga f6e48f654b Remove test dependecies on specific relay clients (#2898) 2024-04-10 10:28:37 +02:00
Serban Iorga 4aa9594dd3 polkadot-sdk backport leftovers (#2896) 2024-04-10 10:28:37 +02:00
Svyatoslav Nikolsky cc22d231e3 relayer waits until chain spec version matches the configured in Client constructor/reconnect (#2894) 2024-04-10 10:28:37 +02:00
Serban Iorga 449ea7b5bb Move relay clients to separate folder (#2893) 2024-04-10 10:28:37 +02:00
Serban Iorga 9b685d5fc9 [Backport from polkadot-sdk] Move chain definitions to separate folder (#2892)
* [Bridges] Move chain definitions to separate folder (#3822)

Related to
https://github.com/paritytech/parity-bridges-common/issues/2538

This PR doesn't contain any functional changes.

The PR moves specific bridged chain definitions from
`bridges/primitives` to `bridges/chains` folder in order to facilitate
the migration of the `parity-bridges-repo` into `polkadot-sdk` as
discussed in https://hackmd.io/LprWjZ0bQXKpFeveYHIRXw?view

Apart from this it also includes some cosmetic changes to some
`Cargo.toml` files as a result of running `diener workspacify`.

(cherry picked from commit 0711729d25)

* diener workspacify
2024-04-10 10:28:37 +02:00
dependabot[bot] 6420f8c4e2 Bump async-trait from 0.1.78 to 0.1.79
Bumps [async-trait](https://github.com/dtolnay/async-trait) from 0.1.78 to 0.1.79.
- [Release notes](https://github.com/dtolnay/async-trait/releases)
- [Commits](https://github.com/dtolnay/async-trait/compare/0.1.78...0.1.79)

---
updated-dependencies:
- dependency-name: async-trait
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-10 10:28:37 +02:00