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

API organize functions #9368

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

SNeedlewoods
Copy link

This is a small first step towards the new API: #9308

@selsta
Copy link
Collaborator

selsta commented Jun 14, 2024

Can you add a bit more information what you are changing here? The diff is huge.

@SNeedlewoods
Copy link
Author

It was discussed in #no-wallet-left-behind. If you look at these three links for example, you see the functions are out of order:
https://github.com/monero-project/monero/blob/master/src/wallet/api/wallet2_api.h#L142
https://github.com/monero-project/monero/blob/master/src/wallet/api/unsigned_transaction.h#L44
https://github.com/monero-project/monero/blob/master/src/wallet/api/unsigned_transaction.cpp

The feedback was:

I think reorganizing the API to shuffle function order in this case would be fine, as long as that's the only changes in that PR

I agree [...] that probably the most easiest-to-review and least controversial way to do that is indeed making a PR, or making several PRs, that do absolutely nothing else than just reordering.

That's what this PR is about.. Hope that answers your question?

@rbrunner7
Copy link
Contributor

If things go according to plan, this PR is the first in a row of commits that deal with the Wallet API in the /src/wallet/api folder of the Monero codebase. As @SNeedlewoods already mentioned, the plan is outlined in issue #9308, also published on Reddit here.

In short: wallet2 will be removed completely from the Monero codebase. CLI wallet, RPC server, GUI wallet, third-party wallet apps etc. will all use the Wallet API.

This course of action was discussed e.g. here in a meeting of the Seraphis Wallet workgroup.

When looking closer at the code of the Wallet API @SNeedlewoods noticed that things in .h and .cpp file are partially out of order, and private method implementations can be found between public method implementation. See their comment with a good example.

We think that this is unfortunate and can get in the way if we go on and significantly enlarge the API, and later also do an extensive rewrite of all wallet code that is now in wallet2.cpp. It may also be a nuisance for people like app wallet writers studying the code. Consider that the Wallet API is already pretty important today, but will of course become even more important if wallet2 goes away.

Thus the plan to make this PR was born: We reorder in a very first step, but take care to make it no more painful than absolutely necessary.

Thus this PR makes no other changes than reordering declarations and implementations and removing a few stray comment lines that are of no use, and exclusively deals with Wallet API files.

Thus anything that violates these rules should be seen as an error in the PR that needs correcting.

@0xFFFC0000
Copy link
Collaborator

Thanks for the PR. The hardest part is reviewing all these files and making sure no unintended code changes has been happened.

One thing I will try is to compile modules in both case, and the object file should be same if no code changes has happened. Though the changes is spread to many files, will make it harder.

If anyone has a better idea for reviewing this, I am all ears.

bool ready = false;
if (!m_wallet->multisig(&ready) || !ready) {
m_status = Status_Error;
m_errorString = tr("The wallet must be in multisig ready state");
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is a semantical change here. The original form is here [1]. This new style condition is not deterministically the same as the original form.

  1. https://github.com/monero-project/monero/pull/9368/files#diff-fcae134993cca2b6f1e887a60638f226ab00165e30bd4d326c17f0a58e11871fL2068

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for taking a look and good catch. This is not intentional and probably snuck in when rebased. Change was pretty recent 3a47cda

Regarding your comment below, this PR is already supposed to be the broken down version of a bigger/messier PR, so if you find anything that's not "ordering functions", it does not belong, but creeped in. Except removing some comments which would get removed with the next PR, because I thought having two PRs (first move comment, second remove comment) will also be unnecessary reviewers work.

@0xFFFC0000
Copy link
Collaborator

My apologies for being a bummer. But we have to make sure that no semantical changes are inside this PR as @rbrunner7 mentioned.

The size of the PR is huge. Maybe we can break into many PRs. First only and only whitespace, then some semantical changes if necessary [1].

  1. API organize functions #9368 (comment)

Copy link
Contributor

@rbrunner7 rbrunner7 left a comment

Choose a reason for hiding this comment

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

This must be the dumbest review I ever did :)

But everything is ok, I wasn't able to unearth a single true code change. For a small number of questionable other changes I left comments. After those are addressed I am ready to approve.

@@ -96,6 +196,7 @@ bool UnsignedTransactionImpl::sign(const std::string &signedFileName)
return true;
}


Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like an unmotivated whitespace change to me, I don't think an additional empty line is in order here ...

{
return m_unsigned_tx_set.txes.size();
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Just a comment, maybe for fellow reviewers: There are 5 whitespace changes included in that big moved and partially reordered code block, 5 lines where trailing extra blanks where removed, which is IMHO a good thing.

Otherwise they are identical, as they should be (verified mechanically with a file comparison tool).

return m_http_client.set_proxy(address);
}

// Static
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this // Static a new, additional comment, or does it come from some "old" place? If it's new, it probably shouldn't be there.

Copy link
Author

Choose a reason for hiding this comment

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

You're right, it's new and shouldn't be here. Will ask for general opinions on such "block separator" comments in today's meeting.

*/
virtual bool verifyMessageWithPublicKey(const std::string &message, const std::string &publicKey, const std::string &signature) const = 0;

// Static
Copy link
Contributor

Choose a reason for hiding this comment

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

This // Static looks like new, and maybe not worth it. Comments will come in a second round, right?

//! sets proxy address, empty string to disable
virtual bool setProxy(const std::string &address) = 0;

// Static
Copy link
Contributor

Choose a reason for hiding this comment

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

Another // Static one ...

Copy link
Contributor

Choose a reason for hiding this comment

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

In this file also some whitespace changes complicate the mechanical comparison with a tool somewhat, but again that's ok, and removed trailing blanks progress, IMHO.

Otherwise no more logic changes, after the one detected by @0xFFFC0000 is corrected now.

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.

None yet

4 participants