From 4b7742d10121f0a90a6ac49cfb00efc0b31aafea Mon Sep 17 00:00:00 2001 From: Harald Heckmann Date: Mon, 5 Feb 2024 18:09:47 +0100 Subject: [PATCH] Elaborate on managed asset destruction in readme --- zrml/asset-router/README.md | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/zrml/asset-router/README.md b/zrml/asset-router/README.md index 48a4fd617..69dfe0391 100644 --- a/zrml/asset-router/README.md +++ b/zrml/asset-router/README.md @@ -6,6 +6,21 @@ handles the asset class of the asset in question, as the asset router internally routes the call to the appropriate pallet as defined in the pallet's configuration. It implements various ORML `MultiCurrency` traits as well as various `Fungible` traits, thus it can be used in other pallets that require -those implementation (such as ORML Currencies). The asset router also provides a -garbage collector for destructible assets, that handles asset destruction -whenever on-chain execution time is available. +those implementation (such as ORML Currencies). The asset router also provides +managed asset destruction, that handles asset destruction for all the assets +registered through the `ManagedDestroy` interface whenever on-chain execution +time is available. + +## Managed Asset Destruction + +Once an asset was registered for managed destruction, it's assigned a state and +stored in a sorted list within the `DestroyAssets` storage. Whenever weight is +available in a block, this pallet will process as many assets as possible from +that sorted list. To achieve that, it loops through all assets one by one and +for each asset, it runs through a state machine that ensures that every step +necessary to properly destroy an asset is executed and that the states are +updated accordingly. It might occur that the pallet that does the actual +destruction, i.e. that is invoked by the managed destruction routine to destroy +a specific asset (using the `Destroy` interface), throws an error. In that case +an asset is considered as `Indestructible` and stored in the +`IndestructibleAssets` storage, while also logging the incident.