Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove 0123 0124 detection to determine POS/POR #1270

Closed
wants to merge 12 commits into from

Conversation

iFoggz
Copy link
Member

@iFoggz iFoggz commented Aug 19, 2018

This POR removes the ability to have to use 0123 0124 in stake amount.

Feel Free To NIT and PICK to make this better then its current state.

Made an enum MinedType in wallet.h:

  • POR
  • POS
  • ORPHANED
  • UNKNOWN
    Reasoning to go beyond POS/POR:
    In cases where a block is orphaned the block does not exist anymore so you can't pull the transaction and blockhash it is apart of. we should consider an icon as for now i'm using the ! icon
    I've also added UNKNOWN thou I do not think we should run into a case of such, plz comment on that

GenerateType function added:
Looks for the blockhash and if it cannot find it returns MinedType::ORPHANED
If block is found for the transaction of the coinstake then It will check the Research Subsidy field (which seems like the best bet for this kind of implementation:
If finds 0 subsidy it returns MinedType::POS
if finds > 0 subsidy it returns MinedType::POR
Should not find anything less the 0 if so MinedType::UNKNOWN this could be in case a bug ever came through that resulted in a negative ResearchReward. (open to removal)

transactiontablemode.cpp:

Changed the detection for the icons based on new implementation
Changes the text shown for the type of mined block based on new implementation

rpcwallet.cpp:

Changes listtransactions to use new implementations

removed:
IsPoR and IsPoR2 functions

Only last part to remove would be the lines from main.cpp:
if (nBoinc > 1) { std::string sTotalSubsidy = RoundToString(CoinToDouble(nTotalSubsidy)+.00000123,8); if (sTotalSubsidy.length() > 7) { sTotalSubsidy = sTotalSubsidy.substr(0,sTotalSubsidy.length()-4) + "0124"; nTotalSubsidy = RoundFromString(sTotalSubsidy,8)*COIN; } }
My changes are not mandatory and backward compatible. the above lines for the final change would likely be mandatory since it is in GetProofOfStakeReward so this change is safe to merge till a mandatory that we modify GetProofOfStakeReward with say a block 10 or 11 change for that. this will now not change the last 4 digits of reward once removed as well.

I did think about putting this somewhere in wallet however with rebase coming over the next while this would complicate things more i'm sure so it is separated.

This should have a more positive impact on issue #1269 on a cosmetic at this time and we should consider the above code change with the release of cbr and @jamescowens split stake. bonus is we can also now even at ease add even an icon so another wallet receiving a split could show up that icon based on the vouts meaning separate icon for stake split

@tomasbrod
Copy link
Member

Should fix #303

@jamescowens
Copy link
Member

jamescowens commented Aug 20, 2018 via email

@iFoggz
Copy link
Member Author

iFoggz commented Aug 21, 2018

with tests from this i have not checked 0123/0124 to determine the type.

@tomasbrod
Copy link
Member

Related to #973

@jamescowens
Copy link
Member

Maybe this is the place to anticipate MRC as well?

{
return tr("Mined - Interest");
}
if (wtx->RemoteFlag==1 && false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we can nuke this section since it's not executed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10-4

@iFoggz
Copy link
Member Author

iFoggz commented Aug 22, 2018

fixed mistake and took out remote flag and working to implement the side stake/reward distribution detection.

@jamescowens
Copy link
Member

jamescowens commented Aug 22, 2018

So here are some pointers on this from this PR and #1265's point of view...

In the normal flow... no splitting, no sidestaking, the CreateCoinStake does...

miner.cpp:562 scriptPubKeyKernel = CoinTx.vout[CoinTxN].scriptPubKey;

This output is from the stake and is the single stake input to the coinstake transaction. The CBR and the rewards are all merged back onto the single output (besides the empty one).

The new SplitCoinStakeOutput function for V10 allows up to 6 destinations for the distribution of rewards, and the remainder (8 - # of distribution outputs - 1 empty) for splitting...

Each sidestake distribution can have a different valid address...

So what we end up with after all is said and done is...

vout[0] empty
vout[1] (coinstake (return) + (CBR + reward remainder))/n split at scriptPubKeyKernel (same as coinstake input)
...
vout[n] (coinstake (return) + (CBR + reward remainder))/n split at scriptPubKeyKernel (same as coinstake input)
vout[n+1] CBR + reward distribution 1 at valid sidestakeaddress 1
...
vout[n+m] CBR + reward distribution m at valid sidestakeaddress m

where n + m <= 7 and m <= 6 and sum(vout[n+1].nValue ... vout[n+m].nValue) <= CBR + RR from CreateGridcoinRewards (because 100% or less of the total CBR + RR can be distributed via sidestaking).

Note that vout[1] ... vout[n] the scriptPubKeyKernel guarantees that vout[1].... vout[n] all satisfty IsMine, because they have a key that is from an address that is associated with the staking input from the wallet.

Note that vout[n+1]... vout[n+m] the addresses can be...

  1. External (to another wallet) (not IsMine)
  2. Internal (back to an address in the wallet) (IsMine)
  3. Internal and the same address as the coinstake vout[1]... vout[n].

Note if a sidestake entry that has an address back to self is used, Condition 3 is guaranteed to happen sooner or later, because any mature coins in a wallet address have a chance to stake, hence it is possible and will occur that the coinstake input could have the same address as one of the reward distributions. This is certainly ok...

What needs to show up in the wallet UI is the following...

what is shown in the staking wallet
sum(vout[1].nValue... vout[n].nValue) +
sum(vout[n+1].nValue... vout[n+m].nValue where the vouts have the same address as vout[1] ) -
stake input.nValue = Mined - Interest or Mined POR if > 0, otherwise suppressed (because without residual CBR or rewards folded back in it is simply the coinstake input return to output without any mint so net for this set is zero...)

Which one, Mined - Interest or Mined - POR depends on whether CreateGridcoinRewards just added CBR or also added in some POR too. (That is what we were talking about earlier...)

what is shown in the sidestake wallet(s)
sum(vout[n+1].nValue.... vout[n+m].nValue where the vout[1]'s address (key) or equivalently the coinstake input address (key) is different than the vout's AND vout[1] is NOT isMine... AND vout[n+1].... vout[n+m] isMine)
= SideStake Mined - Interest or SideStake Mined - POR
depending on whether POR was actually distributed or just CBR... The reason this works is vout[1] NOT isMine shows the stake originated from another wallet. If vout[n+1].... vout[n+m] isMine, then each one that isMine these must be allocated rewards from another staking wallet.

@denravonska denravonska added this to the Camilla milestone Aug 27, 2018
@iFoggz
Copy link
Member Author

iFoggz commented Sep 10, 2018

merge conflicts out the butt so i remade this.

@iFoggz iFoggz closed this Sep 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants