Skip to content

Conversation

@shamil-gadelshin
Copy link
Collaborator

This PR introduces two "accounting maps" that are populated during the root claim:

    /// --- MAP ( subnet ) --> claimed root alpha (kept)
    #[pallet::storage]
    pub type SubnetRootClaimKeep<T: Config> =
        StorageMap<_, Blake2_128Concat, NetUid, AlphaCurrency, ValueQuery, DefaultZeroAlpha<T>>;

    /// --- MAP ( subnet ) --> claimed root alpha (swapped)
    #[pallet::storage]
    pub type SubnetRootClaimSwap<T: Config> =
        StorageMap<_, Blake2_128Concat, NetUid, AlphaCurrency, ValueQuery, DefaultZeroAlpha<T>>;

Maps will be cleared on the network deregistration.
Tests verify alpha addition during root claim for both swap and keep operations, and map clearing on network deregistration.

@shamil-gadelshin shamil-gadelshin self-assigned this Dec 11, 2025
@shamil-gadelshin shamil-gadelshin added the skip-cargo-audit This PR fails cargo audit but needs to be merged anyway label Dec 11, 2025
@bdmason
Copy link
Contributor

bdmason commented Dec 16, 2025

@shamil-gadelshin sorry I put this on the wrong PR before:

When we chatted I said these were fine as Alpha, but now I'm trying to work with it I've realised we need them as TAO. To use them practically we need to take diffs between blocks, but the alpha swapped/kept at different blocks isn't priced the same.

For example, if in block 10 the price of alpha is 0.5, then by block 20 the price is 0.8, and in between those blocks random amounts of alpha were sold each block, we would read the diffs of the root kept/swapped values at block 10 & 20 to find the flow during those 10 blocks, but we wouldn't know what alpha price to use without reading storage at every single block.

@shamil-gadelshin
Copy link
Collaborator Author

Update: original maps were removed in favor of the temporary (in-block) storage and event from on_finalize().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-cargo-audit This PR fails cargo audit but needs to be merged anyway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants