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

Fix for Payment Request reorganizations #456

Merged

Conversation

Projects
None yet
3 participants
@aguycalled
Copy link
Member

commented Apr 30, 2019

This PR prevents payment requests with invalid hashes (not set yet or out of the main chain) to count for the already requested balance of a proposal.

@mxaddict

This comment has been minimized.

Copy link
Contributor

commented Apr 30, 2019

@aguycalled I see that your travis-ci run for this PR on x86_64 linux is failing with similar error to my test, any ideas on what the cause is?

@aguycalled aguycalled force-pushed the aguycalled:ignore-preq-invalid-hash-patch branch to ca7e88b May 1, 2019

@aguycalled aguycalled requested a review from mxaddict May 1, 2019

@mxaddict
Copy link
Contributor

left a comment

I'm not really familiar with the logic in the wallet CFUND code, so I don't think I'm qualified to review that.

But the changes i the unit test seem good.

I just need you to make 1 edit

@@ -3246,7 +3246,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
} else if (out.scriptPubKey.IsPayToPublicKey() || out.scriptPubKey.IsColdStaking()) {
uint160 hashBytes;
int type = 0;
CTxDestination destination;

This comment has been minimized.

Copy link
@mxaddict

mxaddict May 1, 2019

Contributor

Maybe we should add .editorconfig to the project?

This comment has been minimized.

Copy link
@mxaddict

mxaddict May 1, 2019

Contributor

So we can standardize the white space and some other basic configs

This comment has been minimized.

Copy link
@aguycalled

aguycalled May 1, 2019

Author Member

+1

aguycalled added some commits May 1, 2019

@aguycalled aguycalled changed the title Ignore payment requests with invalid hashes Fix for Payment Request reorganizations May 1, 2019

@aguycalled

This comment has been minimized.

Copy link
Member Author

commented May 1, 2019

The issue this PR fixes can be reproduced as follows:

NODE1> staking false
NODE2> staking false
NODE2> addnode 127.0.0.1:node1port onetry
NODE1> generate 300
NODE1> donatefund 100
NODE1> getnewaddress
Save output in %1
NODE2> getnewaddress
Save output in %2
NODE1> sendtoaddress %2 5000000
NODE1> createproposal %1 100 3600 test
Save hash in %3
NODE1> generate 1
NODE2> listproposals
Assert output.size > 0
NODE1> proposalvote %3 yes
NODE1> generate 250
NODE1> createpaymentrequest %3 100 test true
Save output in %4
NODE2> disconnectnode 127.0.0.1:node1port
NODE1> forcetransactions [“%4”]
NODE2> forcetransactions [“%4”]
NODE1> staking true
Wait for 3+ blocks.
Store best block hash in %5
NODE1> staking false
NODE2> staking true
Wait for 1 block. Node 2 only has one output so it will only stake once.
NODE2> staking false
NODE2> addnode 127.0.0.1:node1port onetry
Check that Node2.bestblockhash == %5

Tested succesfully with 2 nodes locally in devnet.
RPC test unit needs to be added.

@mxaddict
Copy link
Contributor

left a comment

Test looks good.

@craigmacgregor

This comment has been minimized.

Copy link
Member

commented May 1, 2019

compiling and starting to review this now.

@mxaddict

This comment has been minimized.

Copy link
Contributor

commented May 1, 2019

compiling and starting to review this now.

Looks like the latest build has an issue with cfund-paymentrequest-state-reorg.py

@mxaddict

This comment has been minimized.

Copy link
Contributor

commented May 2, 2019

@craigmacgregor

This comment has been minimized.

Copy link
Member

commented May 2, 2019

Roger that.

You mean ACK :P

@mxaddict

This comment has been minimized.

Copy link
Contributor

commented May 2, 2019

Roger that.

You mean ACK :P

I see ACK on alot of opensource projects, what does it actually stand for? :)

@craigmacgregor

This comment has been minimized.

Copy link
Member

commented May 2, 2019

Roger that.

You mean ACK :P

I see ACK on alot of opensource projects, what does it actually stand for? :)

It's just short for "Acknowledged" AFAIK.

see: bitcoin/bitcoin#6100

@aguycalled

This comment has been minimized.

Copy link
Member Author

commented May 2, 2019

I've changed the check so it looks at chainwork instead of nbits.
chainwork = prevblock.chainwork + nbits

aguycalled added some commits May 2, 2019

@mxaddict

This comment has been minimized.

Copy link
Contributor

commented May 2, 2019

Looks like final commit fixed the issue with the test.

@craigmacgregor ready to merge? :)

@craigmacgregor

This comment has been minimized.

Copy link
Member

commented May 2, 2019

Travis failing again. Investigating.

@aguycalled

This comment has been minimized.

Copy link
Member Author

commented May 2, 2019

it's failing again uniquely because of a random fee in the coldstaking_* tests

@aguycalled aguycalled requested a review from mxaddict May 2, 2019

@craigmacgregor

This comment has been minimized.

Copy link
Member

commented May 2, 2019

my local build and tests pass on Ubuntu 18.04, waiting for Travis.

@craigmacgregor craigmacgregor merged commit 688bf4d into navcoin:master May 2, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

craigmacgregor added a commit to craigmacgregor/navcoin-core that referenced this pull request May 2, 2019

craigmacgregor added a commit to craigmacgregor/navcoin-core that referenced this pull request May 2, 2019

@craigmacgregor craigmacgregor referenced this pull request May 2, 2019

Merged

v4.6.0 rc #444

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.