Skip to content

Commit

Permalink
Elaborate on managed asset destruction in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
sea212 committed Feb 5, 2024
1 parent d856562 commit 4b7742d
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions zrml/asset-router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit 4b7742d

Please sign in to comment.