anoma / namada

Rust implementation of Namada, a Proof-of-Stake L1 for interchain asset-agnostic privacy
https://namada.net
GNU General Public License v3.0
2.38k stars 950 forks source link

Separate accounting for shielded rewards #1730

Closed cwgoes closed 1 day ago

cwgoes commented 11 months ago

We should keep a counter of all shielded rewards paid (separately from the MASP balance)

cc @bengtlofgren @mariari @juped

cwgoes commented 11 months ago

We should also test that we can never withdraw more rewards than were originally paid.

murisi commented 1 month ago

@cwgoes I just want to clarify: is the goal to augment the namadac --balance command to indicate to the user how much of their balance is due to receiving MASP rewards? If so, this would take at most a day. Or do you have something else in mind?

cwgoes commented 1 month ago

No - the goal is to track in state (accessible with a distinct query command) the total NAM that have ever been allocated (minted through inflation) to shielded rewards and could potentially be withdrawn by using the convert circuit. It's possible that we even do this already - I'm not sure.

murisi commented 1 month ago

Ah, I see. This should be straightforward. This is the variable that holds the total reward to be distributed on an epoch boundary: https://github.com/anoma/namada/blob/5a5838a528ace84c03a1dfc818a50450f6d09459/crates/shielded_token/src/conversion.rs#L288 . We just need to accumulate it.

Probably this task can be done in a few hours. Steps: