-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Introduce XCM matcher for writing barriers #6756
Conversation
This could potentially be |
This pull request has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/new-matcher-api-facilitating-the-building-of-xcm-barriers/2126/1 |
})?; | ||
Ok(()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
})?; | |
Ok(()) | |
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
})?; | |
Ok(()) | |
}) | |
.map(|_| ()) |
But this is why I opted for the Ok(())
at the end instead -- because the Ok
type is not ()
but rather Self
.
fn match_next_inst<F>(self, f: F) -> Result<Self, Self::Error> | ||
where | ||
Self: Sized, | ||
F: FnMut(&mut Self::Inst) -> Result<(), Self::Error>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this whole API exclusively tailored to mutable Instruction slices?
That seems to limit the environments that it can be used in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because you may want to mutate the instruction whilst iterating through it -- this is how the AllowUnpaidExecutionFrom
barrier works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But can we then not have two flavours? One for mut and one normal? Or do you think its not worth it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure how it is limited tbh, we mutably borrow instructions one at a time, so unless there is another (mutable) borrow of the same instruction somewhere else, it shouldn't restrict the places in which you can use this API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition, the Matcher
struct already mutably borrows the entire slice, so the mutable borrow of the instruction here isn't really doing anything worse than that; instead, it's narrowing the scope of the mutable borrow to a single instruction.
bot merge |
* master: (27 commits) bump `zombienet` version to v1.3.37 (#6773) Bump `blake2b_simd` to 1.0.1 (#6829) changelog: update template for new label behavior (E3/E4) (#6804) Companion for paritytech/substrate#12828 (#6380) Don't send `ActiveLeaves` from leaves in db on startup in Overseer (#6727) Polkadot XCM Body constants (#6788) Decrease expected peer count in zombinenet tests (#6826) Additional tracing in `provisioner`, `vote_selection` and `dispute-coordinator` (#6775) Change node-key for bootnodes (#6772) Change handle_import_statements to FatalResult (#6820) Introduce XCM matcher for writing barriers (#6756) Freeze note on `SessionInfo`. (#6818) Bump parity-db (#6816) Removing Outdated References to Misbehavior Arbitration Subsystem (#6814) Forgotten re-export for `MatchedConvertedConcreteId` (#6815) Companion for substrate#13509: bump API versions of {Beefy,Mmr}Api (#6809) Migrate to `Weight::from_parts` (#6794) [XCM] Multiple `FungiblesAdapter`s support + `WeightTrader::buy_weight` more accurate error (#6739) Get rid of unnecessary cloning and work. (#6808) changelog: fix migration listing (#6806) ...
* master: (27 commits) bump `zombienet` version to v1.3.37 (#6773) Bump `blake2b_simd` to 1.0.1 (#6829) changelog: update template for new label behavior (E3/E4) (#6804) Companion for paritytech/substrate#12828 (#6380) Don't send `ActiveLeaves` from leaves in db on startup in Overseer (#6727) Polkadot XCM Body constants (#6788) Decrease expected peer count in zombinenet tests (#6826) Additional tracing in `provisioner`, `vote_selection` and `dispute-coordinator` (#6775) Change node-key for bootnodes (#6772) Change handle_import_statements to FatalResult (#6820) Introduce XCM matcher for writing barriers (#6756) Freeze note on `SessionInfo`. (#6818) Bump parity-db (#6816) Removing Outdated References to Misbehavior Arbitration Subsystem (#6814) Forgotten re-export for `MatchedConvertedConcreteId` (#6815) Companion for substrate#13509: bump API versions of {Beefy,Mmr}Api (#6809) Migrate to `Weight::from_parts` (#6794) [XCM] Multiple `FungiblesAdapter`s support + `WeightTrader::buy_weight` more accurate error (#6739) Get rid of unnecessary cloning and work. (#6808) changelog: fix migration listing (#6806) ...
This pull request has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/polkadot-release-analysis-v0-9-40/2468/1 |
Resolves #4276.
Introduces a new API
fn matchers()
for&mut [Instructions<Call>]
that is similar to iterators: it can advance the current instruction to the next while ensuring the current instruction matches/fulfills a certain condition; it can assert the remaining number of instructions left to process; and it can also skip instructions while a condition is being evaluated as true.The main purpose of creating a Matcher API instead of using iterators is that of purpose and clarity -- it is much easier to maintain, audit and write matchers over iterators, as they are intended to be declarative in nature.