Conversation
|
Still haven't reviewed the code, but a few comments about the description from above:
This is actually the correct way to do it. Going through "spend" is wrong, as spend should only be used by callers from the outside. This is the same issue I discussed with Aaro and Amin about smart contracts. We should never create intermediary transactions to modify the state of the database, but we should directly modify the database to the state we need. The other correct alternative is to expect the user to create a transaction that will be interpreted by the We should never create intermediary transactions to change the state of the UTXO set. Usually people do this in bitcoin forks because they want to be able to rebase on bitcoin and to be able to simplify the security model of spending/unspending. But in our case, we don't have to do any of that as we don't even have a base security model to worry about.
Well, I don't know what to say about this, but we're (again) using balances for staking. I can't blame you for doing this, but ideally staking would be based on outputs, not balances. But given that we have to mimic pallet-staking without using pallet-balances and not reinvent the wheel, I think that's OK. Using the total stake in the network for the raffle sounds like the correct way to do this as it defines your weight as a staker. |
| session_keys: Vec<u8>, | ||
| value: Value, | ||
| ) -> DispatchResultWithPostInfo { | ||
| let (total, hashes, utxos) = pick_utxo::<T>(&stash, value); |
There was a problem hiding this comment.
This is really bad from a practical point of view. So we're looping over all existing UTXOs to find some UTXOs for this user, so that we can lock for him. We're acting like a wallet... but not exactly, because we have to loop over everything.
The more practical way is to have the user create the transaction and spend the outputs he thinks are fit to be staked. Then, in the spend function, while verifying, we see what outputs he created, and the user chooses what outputs should be used for staking.
A copy of Substrate's
pallet-stakingtoremove pallet-balancesdependency.For this iteration, here are the following things I focused on:
nominatorssessionrelated traits to increase the session number and the era numberA couple of things I made that has to be addressed:
pallet-stakinguses thetotal_issuanceto do elections and votings. Talking to Anton about it, we didn't really know where to start. So for now, I use the overall stake by all stash accounts and use that as basis.lock_for_staking, it is better to call thespend()function of Utxo. But given the problem of signing transactions inside the pallet, I took a shortcut and just inserted directly to the the storage ofUtxoStoreandLockedUtxos.lock_for_stakingto work, but it is obviously the wrong way.^ Aside from those, more things to do:
StakingCountfrom the UtxoStakingHelper.locked_utxosin the GenesisConfig of Utxolock_extra_for_staking+ the other actionspallet-stakingthat is not important.lock_for_stakingin the Utxo work, by connecting to mypallet-utxo-staking