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

Removal of 0123 0124 & implementation of MinedType GetGeneratedType - II #1390

Merged

Conversation

jamescowens
Copy link
Member

This is a continuation of Paul's #1295, rebased, debugged, and enhanced, with the icons from the new UI.

@jamescowens jamescowens changed the title Staging removal of 01234 Removal of 0123 0124 & implementation of GenerateType/MinedType - Part II Jan 21, 2019
@jamescowens jamescowens changed the title Removal of 0123 0124 & implementation of GenerateType/MinedType - Part II Removal of 0123 0124 & implementation of GenerateType/MinedType - II Jan 21, 2019
@denravonska denravonska added this to the Camilla milestone Jan 21, 2019
@jamescowens
Copy link
Member Author

jamescowens commented Jan 24, 2019

Addresses #303 and #1269

@jamescowens
Copy link
Member Author

Tomas/Ravon.... I know this implementation is not ideal, but it is good enough and works. We still have oddities with listtransaction rpc calls, but these issues pre-date this PR and in fact exist in 4.0.1.0. So I would like to get this merged into Camilla.

@jamescowens
Copy link
Member Author

I will do a separate PR for the minor issue of putting info on sidestaking and splitting status into the getinfo.

@jamescowens
Copy link
Member Author

Tomas?

case MinedType::POR : strHTML += tr("MINED - POR"); break;
case MinedType::ORPHANED : strHTML += tr("MINED - ORPHANED"); break;
case MinedType::POS_SIDE_STAKE : strHTML += tr("POS SIDE STAKE"); break;
case MinedType::POR_SIDE_STAKE : strHTML += tr("POR SIDE STAKE"); break;
Copy link
Member

Choose a reason for hiding this comment

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

When MINED - POS, this should be SIDE STAKE - POS

Copy link
Member Author

Choose a reason for hiding this comment

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

No, because the side stake is only on the output that has an address that is different than the stake input. The stake return to the original miner on the original address of the staking UTXO input is not a side stake. We have discussed creating a different category for returns to the original staker which is the remainder, after the distribution of the side stake to the receiving address. This would require creating two more enum categories to handle that.

Copy link
Member

Choose a reason for hiding this comment

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

Is it right when I say, The POS_SIDE_STAKE (and por) is shown only in wallet of the receiver of the sidestake? I do not understand why it should be worded in different word order than MINED - POS (and por).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. POS_SIDE_STAKE and POR_SIDE_STAKE is only shown on the receiving wallet. The remainder which returns to the source wallet after the side stake distribution is simply labeled POS or POR... I will post pictures...

Copy link
Member Author

Choose a reason for hiding this comment

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

The reasoning is that the remainder that returns is just like a normal stake return, except it is a lower amount because sidestakes have been taken out. This return is not to another address, hence the return itself is not a sidestake.

A strong argument can be made to create two more entries in the enum to handle the stake returns after a POS or POR sidestake has been taken out, to indicate that the full amount is not coming back to the staking address. I am open for that, and we would use the gold or purple cube with the red top to indicate that, much like we are using the gold cube with the green top to indicate the receiver of the side stake.

Copy link
Member Author

Choose a reason for hiding this comment

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

It isn't necessary though, and I rather would do this in an additional PR, probably coupled with the UI work rather than mess further with it here... We need to get Camilla out of the door.

Copy link
Member Author

Choose a reason for hiding this comment

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

sidestake source
sidestake destination

Copy link
Member Author

Choose a reason for hiding this comment

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

The red boxes are the stake returns to the source wallet for a POR and POS style stake. (The reason that wallet had both a POR and POS is the minimum block span between two consecutive research rewards was not satisfied.

The green boxes are the destination wallet of the sidestaking. In this particular case, there are two different sidestake entries pointing to different addresses in the same wallet. It shows separate transactions as intended...

// Count the number of outputs that have a pubkey equal to the first (non-empty) output.
// This are the stakesplits.
if (txout.scriptPubKey == wtx.vout[1].scriptPubKey)
nNumberOfOutputs++;
Copy link
Member

Choose a reason for hiding this comment

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

This can fail, because on splitstake, the first output is P2PK, while the second is P2PKH. See https://hr.tbrada.eu/gbx/block/2ae492a0f1868d0b83b17b3b1073d04683f389be7bb8a683c9b0864489be2aa2

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that second output was a sidestake, not splitstake. The intention here is to merge split UTXO's NOT sidestake UTXOs. So I disagree with you.

For example, if there are three vouts that are UTXO splits (i.e. back to the same address as the input, or equivalently vout[1]), then we want those three merged together into a net transaction for display. Conversely, if there are sidestakes to other addresses those should be separated out. I have confirmed this to work properly in test,

Copy link
Member

Choose a reason for hiding this comment

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

First part correct. The transaction was indeed side-stake. And I fully agree with the second paragraph.

What raised my concern was equivalence comparison of output scripts and the evidence that side-stake scripts are different than return-stake. And they would be unequal even if directed to the same address.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. And that would cause them to be printed out as separate "transactions" in the UI, which is exactly what we want. A sidestake looped back to the same address will be shown as a separate transaction from the (split) stake return...

src/wallet.cpp Outdated
@@ -2611,3 +2611,53 @@ void CWallet::GetKeyBirthTimes(std::map<CKeyID, int64_t> &mapKeyBirth) const {
mapKeyBirth[it->first] = it->second->nTime - 7200; // block times can be 2h off
}

MinedType GenerateType(const uint256& tx, unsigned int vout)
Copy link
Member

Choose a reason for hiding this comment

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

Can this function be renamed so it does not suggest that the Type is going to be Generated?

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess so. This was Paul's choice.

Copy link
Member Author

Choose a reason for hiding this comment

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

What would you like it to be called?

Copy link
Member

Choose a reason for hiding this comment

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

getGenerateType, getTypeOfGenerated, TypeOfGeneration, (get)GenerationTxType

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed it to getGeneratedType which is more descriptive and not misleading.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think you pushed that change. Also, uppercase 'G' :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@jamescowens
Copy link
Member Author

Ok. This should be ready to go now.

@jamescowens
Copy link
Member Author

WTF. I did a chmod because some of the files were 755 for some reason and it took that but not the actual change?

match to what the function is doing.
@jamescowens
Copy link
Member Author

Ok. Should be there now...

@jamescowens jamescowens changed the title Removal of 0123 0124 & implementation of GenerateType/MinedType - II Removal of 0123 0124 & implementation of MinedType GetGeneratedType - II Feb 18, 2019
@denravonska denravonska merged commit 9f77efc into gridcoin-community:staging Feb 19, 2019
@jamescowens jamescowens mentioned this pull request Feb 19, 2019
@jamescowens jamescowens deleted the staging_removal_of_01234 branch April 13, 2019 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants