diff --git a/prdoc/pr_4204.prdoc b/prdoc/pr_4204.prdoc new file mode 100644 index 000000000000..359bc97e853f --- /dev/null +++ b/prdoc/pr_4204.prdoc @@ -0,0 +1,30 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: "`try-runtime`: Add `StateDiffGuard` to record state difference and guard against unexpected storage changes" + +doc: + - audience: Runtime Dev + description: | + This PR adds a `StateDiffGuard` to the `try-runtime` crate. The `StateDiffGuard` is a helper struct + that records the state difference between its initialization and drop. It can be used to guard + against unexpected storage changes and also for recording the state difference for testing, + debugging, and other purposes. + + Example: + ```rust + let _guard = StateDiffGuardBuilder::default() + .must_change(StoragePrefix{ + pallet_name: b"Balances", + storage_name: b"TotalIssuance", + }) + .build(); + + // do something that may change the storage + + // the guard will panic if the storage is changed unexpectedly at the end of the scope + ``` + +crates: + - name: frame-support + bump: minor