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

Use bisq's bitcoinj 0.15.8 - september 2020 #4504

Merged
merged 40 commits into from
Sep 19, 2020

Conversation

oscarguindzberg
Copy link
Contributor

Adapt Bisq to bitcoinj 0.15.8 (see https://github.com/bisq-network/bitcoinj/commits/bisq_0.15.8)
That is a pre-requisite for segwit support.
This PR replaces #4270

@boring-cyborg boring-cyborg bot added in:altcoins is:no-priority PR or issue marked with this label is not up for compensation right now labels Sep 9, 2020
@oscarguindzberg
Copy link
Contributor Author

I see codacy suggested a couple of changes, I will fix them ASAP

}

@Override
public ImmutableList<ChildNumber> accountPathFor(Script.ScriptType outputScriptType) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Aren't there more script types (MultiSig) to check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even though Bisq uses multisig (eg for payout tx signing), bisq does not use a multisig keychain.
A multisig keychain (MarriedKeyChain in bitcoinj) makes sense when you want to repeatedly generate new multisig addresses for the same group of people.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, thanks. Did not see the full context.

@@ -172,7 +172,6 @@ public WalletsSetup(RegTestHost regTestHost,

btcWalletFileName = "bisq_" + config.baseCurrencyNetwork.getCurrencyCode() + ".wallet";
params = Config.baseCurrencyNetworkParameters();
PeerGroup.setIgnoreHttpSeeds(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Are httpSeed still used by default in BitcoinJ? If so I would prefer to still make sure to not use http seeds as they have some privacy issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

http seeds are not used by default in bitcoinj and are not used in bisq as is.
Having said that, I had another look at this and found they might be used if a bisq dev activates a certain feature of bitcoinj that is not being used today. So, I will add PeerGroup.setIgnoreHttpSeeds(true) again.

@@ -495,6 +485,8 @@ private Wallet loadWallet(boolean shouldReplayWallet, File walletFile, boolean i
}

protected Wallet createWallet(boolean isBsqWallet) {
// Change preferredOutputScriptType of btc wallet to P2WPKH to start using segwit
Script.ScriptType preferredOutputScriptType = isBsqWallet ? Script.ScriptType.P2PKH : Script.ScriptType.P2PKH;
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the else case should be P2WPKH

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That will be true when we implement segwit.
For now, this is just migration to bitcoinj 0.15
The code is a placeholder for the code that is coming soon (see the comment in the previous line).
I will update the code to:
Script.ScriptType preferredOutputScriptType = Script.ScriptType.P2PKH;
To avoid confusions until segwit is implemented.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah missed the comment.

@chimp1984
Copy link
Contributor

@ripcurlx why it got flagged incorrectly (altcoin)?

@ripcurlx ripcurlx added the is:priority PR or issue marked with this label is up for compensation label Sep 9, 2020
@ripcurlx
Copy link
Contributor

ripcurlx commented Sep 9, 2020

@ripcurlx why it got flagged incorrectly (altcoin)?

It touches the assets module.

@oscarguindzberg
Copy link
Contributor Author

I fixed codacy suggestions, but 2 of them. They say I should avoid calling toString() on a String object, but actually Sha256Hash.toString() is being called.

@chimp1984
Copy link
Contributor

I fixed codacy suggestions, but 2 of them. They say I should avoid calling toString() on a String object, but actually Sha256Hash.toString() is being called.

Its in TransactionsListItem.java trade.getDepositTx().getTxId().toString()

chimp1984
chimp1984 previously approved these changes Sep 9, 2020
Copy link
Contributor

@chimp1984 chimp1984 left a comment

Choose a reason for hiding this comment

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

preliminary utACK
But I would like to do a more in depth review in a few days. So better wait for after release with merge and another ACK as its high risk area with wallet code changes.

@ripcurlx
Copy link
Contributor

@oscarguindzberg Could you please have a look at the two unnecessary toString calls Codacy is complaining about, so this PR is mergeable? Thanks!

@oscarguindzberg oscarguindzberg force-pushed the bitcoinj_0_15_8_sep_2020 branch 2 times, most recently from f8e202e to 36219de Compare September 16, 2020 16:17
chimp1984
chimp1984 previously approved these changes Sep 16, 2020
Copy link
Contributor

@chimp1984 chimp1984 left a comment

Choose a reason for hiding this comment

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

utACK

Copy link
Member

@sqrrm sqrrm left a comment

Choose a reason for hiding this comment

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

Tested in regtest and wallet conversion seems to have worked fine. Sending coins work fine, BSQ parsing looks correct.

What I haven't done is completely understood the changes to WalletConfig.java. The rest looks ok to me.

@@ -105,9 +107,9 @@ public void onWalletReady(Wallet wallet) {
if (!entrySet.isEmpty()) {
Set<AddressEntry> toBeRemoved = new HashSet<>();
entrySet.forEach(addressEntry -> {
DeterministicKey keyFromPubHash = (DeterministicKey) wallet.findKeyFromPubHash(addressEntry.getPubKeyHash());
DeterministicKey keyFromPubHash = (DeterministicKey) wallet.findKeyFromPubKeyHash(addressEntry.getPubKeyHash(), Script.ScriptType.P2PKH);
Copy link
Member

Choose a reason for hiding this comment

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

Prefer to break lines at 120 characters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -68,22 +68,23 @@ dependencyVerification {
'net.glxn:qrgen:c85d9d8512d91e8ad11fe56259a7825bd50ce0245447e236cf168d1b17591882',
'net.jcip:jcip-annotations:be5805392060c71474bf6c9a67a099471274d30b83eef84bfc4e0889a4f1dcc0',
'net.sf.jopt-simple:jopt-simple:df26cc58f235f477db07f753ba5a3ab243ebe5789d9f89ecf68dd62ea9a66c28',
'network.bisq.btcd-cli4j:btcd-cli4j-core:203156fc63dc1202774de9818e4f21149549f79b25d356b08bb0c784be40c0e8',
'network.bisq.btcd-cli4j:btcd-cli4j-daemon:0a2783a851add6e3d8ae899ade48c041b250bfac64b6a4c5f6380ebcdbbe6848',
'network.bisq.btcd-cli4j:btcd-cli4j-core:4634b39de93764c4609e295e254e8c3b1427ba24febf43352f4f315029c5b1b3',
Copy link
Member

Choose a reason for hiding this comment

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

Upgraded btcd-cli4j, why was this necessary?

Copy link
Contributor Author

@oscarguindzberg oscarguindzberg Sep 17, 2020

Choose a reason for hiding this comment

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

Kind of long story...
A year ago I upgraded some Bisq dependencies to match bitcoinj 0.15.1 dependencies. eg upgraded guava from 20 to 27.
Then, when bitcoinj 0.15.8 came out with guava 28.2 , I upgraded Bisq to use that guava version.
None of those changes were merged yet, we are merging it as part of this PR.

Some time ago this code was merged into the btcd-cli4j repo bisq-network/btcd-cli4j#4 . And then you reverted part of the change bisq-network/btcd-cli4j#8.

So, I am not actually upgrading btcd-cli4j but downgrading it to the version that declares a dependency on guava 27.

In any case, bisq's gradle resolves not to include the guava version declared in btcd-cli4j but the version declared on its own build.gradle file.

To make things clear a new btcd-cli4j version declaring a dependency to guava 28.2-jre could be created, then we could upgrade to that btcd-cli4j version in bisq.

chimp1984
chimp1984 previously approved these changes Sep 17, 2020
Copy link
Contributor

@chimp1984 chimp1984 left a comment

Choose a reason for hiding this comment

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

utACK

@oscarguindzberg
Copy link
Contributor Author

@ripcurlx the two "unnecessary toString() calls Codacy is complaining about" seem like a Codacy bug to me. toString() is being called on Sha256Hash instances, not on String instances.

@oscarguindzberg
Copy link
Contributor Author

@sqrrm @ripcurlx I think this PR is ready for merging. Please, let me know if there is something I did not answer/fix.

@oscarguindzberg
Copy link
Contributor Author

oscarguindzberg commented Sep 17, 2020

@sqrrm I re-requested review from you, I guess that is necessary to merge the PR since I pushed 3 new commits with a bugfix and code styling changes.

sqrrm
sqrrm previously approved these changes Sep 18, 2020
Copy link
Member

@sqrrm sqrrm left a comment

Choose a reason for hiding this comment

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

ACK

Waiting for @ripcurlx to test this before merging as well. Also need a resolution to the codacy complaints.

chimp1984
chimp1984 previously approved these changes Sep 18, 2020
Copy link
Contributor

@chimp1984 chimp1984 left a comment

Choose a reason for hiding this comment

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

utACK

@chimp1984
Copy link
Contributor

@sqrrm @ripcurlx The codady complains are false positives. getTxId() returns a ShaHash and toString() is correct on that. Seems a bug in codacy. Please ignore that and merge or deactivate that rule.

@sqrrm
Copy link
Member

sqrrm commented Sep 18, 2020

Impossible to ignore, it blocks merging. So either we're changing codacy rules or we write bad code to get around codacy. It's a pity that's it's so annoying.

@oscarguindzberg
Copy link
Contributor Author

I just signed my commits. I had to push again. I guess the PR requires approval again.

@chimp1984
Copy link
Contributor

Impossible to ignore, it blocks merging. So either we're changing codacy rules or we write bad code to get around codacy. It's a pity that's it's so annoying.

Thats the real dnager with that too strict and inflexible robot. We bow down and do things we would not do otherwise (for instance i use less exception handling now as it enforces me to write custom exceptions which is often boilerplate, leading at the end to less safe code). We are the masters not codacy.

Copy link
Contributor

@chimp1984 chimp1984 left a comment

Choose a reason for hiding this comment

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

NACK (to last commit bowing down to stupid codacy bot)

I think this is really wrong that we start to write less readible code because of that stupid bot. @ripcurlx Please deactivate codacy until we find a more flexible solution. I find this inacceptable that we cannot override clear mistakes or bad settings in codacy.

@oscarguindzberg
Copy link
Contributor Author

@chimp1984 The last commit (83a1e2f) does not seem wrong or less readable to me, it is just another way to do the same thing. Please, please, don't NACK this PR... it was so hard to be ready to merge. Let's fix codacy in another issue/PR.

Copy link
Contributor

@chimp1984 chimp1984 left a comment

Choose a reason for hiding this comment

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

utACK

@chimp1984
Copy link
Contributor

Ok, I just got too many times annoyed by a tool which seems to makes us slaves.

@sqrrm sqrrm merged commit 9735a85 into bisq-network:master Sep 19, 2020
@cd2357
Copy link
Contributor

cd2357 commented Sep 19, 2020

Impossible to ignore, it blocks merging. So either we're changing codacy rules or we write bad code to get around codacy. It's a pity that's it's so annoying.

@sqrrm are you sure?

I played around with Codacy and it can be ignored when merging:

github-repo-merge-despite-codacy

@sqrrm
Copy link
Member

sqrrm commented Sep 19, 2020

I guess admins can override codacy, but I'm not an admin so I can't.

@cd2357
Copy link
Contributor

cd2357 commented Sep 19, 2020

Hmm.

Alternatively, Codacy can be removed from the "branch protection" settings.

github-codacy-branch-protection

In that case, the Codacy checks are only informative and merging is possible without admin permissions.

github-codacy-branch-protection-result

Which seems like a sane setup.

@cd2357
Copy link
Contributor

cd2357 commented Sep 19, 2020

Other checks can still be enforced though, like successful travis builds.

@sqrrm
Copy link
Member

sqrrm commented Sep 19, 2020

@cd2357 making them recommendations rather than enforced sounds like the more flexible and sane thing to do, all things considered. Thanks for looking that up, @ripcurlx could you make codacy optional? I think it could save some headaches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in:altcoins is:no-priority PR or issue marked with this label is not up for compensation right now is:priority PR or issue marked with this label is up for compensation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants