Skip to content

Conversation

kdcis
Copy link
Contributor

@kdcis kdcis commented Aug 25, 2021

Updated binary operator line change
Added ignore comments for bare except & unicode function warnings

@kdcis kdcis force-pushed the v0.6-codequality-shared branch from 880399c to 502b08d Compare August 26, 2021 07:53
@kdcis kdcis force-pushed the v0.6-codequality-shared branch 2 times, most recently from 431ebd6 to 32389dd Compare August 26, 2021 10:30
@g1itch
Copy link
Collaborator

g1itch commented Aug 26, 2021

What's the point on editing this module? It should be removed soon and even has corresponding docstring.

@kdcis kdcis force-pushed the v0.6-codequality-shared branch 2 times, most recently from fa476c7 to d898703 Compare August 27, 2021 16:21
Copy link
Member

@PeterSurda PeterSurda left a comment

Choose a reason for hiding this comment

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

Try moving the functions into a separate files.

Copy link
Member

@PeterSurda PeterSurda left a comment

Choose a reason for hiding this comment

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

isAddressInMyAddressBook -> src/helper_addressbook.py
isAddressInMySubscriptionsList -> src/helper_addressbook.py
isAddressInMyAddressBookSubscriptionListOrWhitelist -> src/helper_addressbook.py
decodeWalletImportformat -> src/helper_wallet.py
reloadMyAddressHashes -> src/filesystem.py
reloadBroadcastSendersForWhichImWatching -> src/helper_addressbook.py
fixPotentiallyInvalidUTF8Data -> src/helper_unicode.py
checkSensitiveFilePermissions -> src/filesystem.py
fixSensitiveFilePermissions -> src/filesystem.py

@g1itch
Copy link
Collaborator

g1itch commented Aug 31, 2021

decodeWalletImportformat -> src/helper_wallet.py

did you look into #1796? I moved it into highlevelcrypto. In general I'd suggest rather removing those helpers than produce more.

@kdcis kdcis force-pushed the v0.6-codequality-shared branch from d898703 to 80c5c3f Compare September 1, 2021 08:02
@g1itch
Copy link
Collaborator

g1itch commented Sep 1, 2021

fixPotentiallyInvalidUTF8Data -> src/helper_unicode.py

remove? use b''.decode('utf-8', 'ignore') instead?

checkSensitiveFilePermissions -> src/helper_filesystem.py
fixSensitiveFilePermissions -> src/helper_filesystem.py

helper_startup? let's not smear side effects on the codebase.

Also I'd prefer describing the code using packages and modules, not files (or worse - scripts).

@kdcis kdcis force-pushed the v0.6-codequality-shared branch 2 times, most recently from 4b299cb to b421c6e Compare September 2, 2021 07:34
@g1itch g1itch added the formatting Code or UI text formatting label Sep 2, 2021
@PeterSurda
Copy link
Member

fixPotentiallyInvalidUTF8Data -> src/helper_unicode.py

remove? use b''.decode('utf-8', 'ignore') instead?

Ok agree.

checkSensitiveFilePermissions -> src/helper_filesystem.py
fixSensitiveFilePermissions -> src/helper_filesystem.py

helper_startup? let's not smear side effects on the codebase.

I worry we'll have more circular imports if we use helper_startup. These two functions are called from multiple places and not only during startup. So I propose src/filesystem.py.

Also I'd prefer describing the code using packages and modules, not files (or worse - scripts).

Well, there is one question about the final form, and another one about the iterative steps to get there.

@g1itch
Copy link
Collaborator

g1itch commented Sep 3, 2021

I worry we'll have more circular imports if we use helper_startup. These two functions are called from multiple places and not only during startup.

Where? I don't see it:

$ grep -r checkSensitiveFilePermissions src
src/shared.py:    keyfileSecure = checkSensitiveFilePermissions(os.path.join(
src/shared.py:def checkSensitiveFilePermissions(filename):
$ grep -r fixSensitiveFilePermissions src
src/shared.py:        fixSensitiveFilePermissions(os.path.join(
src/shared.py:def fixSensitiveFilePermissions(filename, hasEnabledKeys):

@PeterSurda
Copy link
Member

It's called from reload hashes and this is called from several places.

@g1itch
Copy link
Collaborator

g1itch commented Sep 3, 2021

It's called from reload hashes and this is called from several places.

the reload hashes is still in the shared

@PeterSurda
Copy link
Member

the reload hashes is still in the shared

Yes but I asked for it to be moved too.

@g1itch
Copy link
Collaborator

g1itch commented Sep 3, 2021

the reload hashes is still in the shared

Yes but I asked for it to be moved too.

Maybe move them together, into the wallet or keymanager module I guess. It's a part of the architectural proposals I was going to describe, which is surprisingly implemented in hyperbit: an object holding all the keys, which performs signing/verification and encryption/decryption and can be locked/unlocked with some additional data (e.g. password). As I see it, it should live in the ObjectProcessor thread.

@PeterSurda
Copy link
Member

Well, I'll try to arrange it so that it's not in conflict with your pending PRs, but I think it's OK if it's changed iteratively and moves several times, as long as it keeps working in the meantime. Having more rounds of refactoring shouldn't be an objection, as long as the individual rounds provide some benefit. The purpose of this round is to unburden src/shared.py and reduce cyclical imports.

Regarding key manager, well, I think that's a more complicated issue, as the crypto operations are also used inside singleWorker.

@g1itch
Copy link
Collaborator

g1itch commented Sep 4, 2021

It is not about the PR conflicts. I'm OK with conflicting PRs if they really make the code better, not just replace one bad formatting by another bad formatting or try to solve an issue already addressed in the existing PR.

I think that a proper refactoring needs more research and planning because you can move it by the small steps trying to not break anything, but if you don't know where are you going to end up, the result is not gonna be great.

The main source of the circular imports I can see now is the network.connectionpool. Not here. And this particular module needs more patient analysis which is cannot be done by a person, not familiar with the code, because it's extremely hard and crucial for the whole project. Let's draw some schemas and write a roadmap, maybe? I don't think that ripping up the codebase into the small pieces each in separate file is gonna help. That's not how the good python programs are written.

pyreverse src/network (2021-05-30 20:04:58):

packages

@g1itch
Copy link
Collaborator

g1itch commented Sep 4, 2021

Regarding key manager, well, I think that's a more complicated issue, as the crypto operations are also used inside singleWorker.

It doesn't need the private keys and maybe it shouldn't assemble the packets, just setup the PoW. I'm trying to move all the assemble code into the protocol in #1788.

@PeterSurda
Copy link
Member

It is not about the PR conflicts. I'm OK with conflicting PRs if they really make the code better, not just replace one bad formatting by another bad formatting or try to solve an issue already addressed in the existing PR.

I don't necessarily disagree, but there are other problems to consider. For example, there is a backlog of PRs because they are often too exhausting to review or too difficult to test. The hurdles for new developers are too high. In summary, there is also a need to make it easier for others to contribute. I find it difficult to find experts to work on the project, and even if I do then there are often too many disagreements to get things done.

I think that a proper refactoring needs more research and planning because you can move it by the small steps trying to not break anything, but if you don't know where are you going to end up, the result is not gonna be great.

There are still steps that can be done that make it easier for new developers to contribute, or for more work to be doable in parallel. I think that this PR as an example of that.

The main source of the circular imports I can see now is the network.connectionpool. Not here. And this particular module needs more patient analysis which is cannot be done by a person, not familiar with the code, because it's extremely hard and crucial for the whole project. Let's draw some schemas and write a roadmap, maybe?

I tend to agree about network.connectionpool, but regarding this file, there is also the difference between short term and long term.

I don't think that ripping up the codebase into the small pieces each in separate file is gonna help. That's not how the good python programs are written.

It makes it easier for a new developer to understand the code. In first step, src/shared.py would only contain global variables and no functions. In further steps, the variables may be moved into modules, or a data class, or something else, similarly with functions. In other words, I think that separating utility functions from global state is helpful even if they don't end up in their final destination immediately.

I have a limited time to spend on the codebase, and I know you have too. Therefore I try to focus on guiding others incrementally. I tried to have others do big planned refactorings, but it mostly doesn't work, even with moderately skilled developers it takes forever and nothing gets finished. For example #1794 appears to be roughly the limit of big refactoring that is still has some benefit.

@kdcis kdcis force-pushed the v0.6-codequality-shared branch 4 times, most recently from b55635c to c5614a9 Compare September 10, 2021 15:19
@kdcis kdcis force-pushed the v0.6-codequality-shared branch 2 times, most recently from b1c8d35 to 0ee3235 Compare September 20, 2021 14:50
@kdcis kdcis force-pushed the v0.6-codequality-shared branch 7 times, most recently from 706a63f to 5a8f591 Compare October 4, 2021 07:05
@g1itch
Copy link
Collaborator

g1itch commented Oct 4, 2021

In first step, src/shared.py would only contain global variables and no functions.

There is already the state module, containing the global variables.

@kdcis kdcis force-pushed the v0.6-codequality-shared branch from 5a8f591 to 0ee310b Compare October 5, 2021 06:53
src/api.py Outdated
self.config.save()
queues.UISignalQueue.put(('writeNewAddressToTable', ('', '', '')))
shared.reloadMyAddressHashes()
filesystem.reloadMyAddressHashes()
Copy link
Member

Choose a reason for hiding this comment

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

should be in a different file

broadcastSendersForWhichImWatching = {}


def isAddressInMyAddressBook(address):
Copy link
Member

Choose a reason for hiding this comment

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

helper_sql



# At this point we should really just have a isAddressInMy(book, address)...
def isAddressInMySubscriptionsList(address):
Copy link
Member

Choose a reason for hiding this comment

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

helper_sql

return queryreturn != []


def isAddressInMyAddressBookSubscriptionsListOrWhitelist(address):
Copy link
Member

Choose a reason for hiding this comment

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

helper_sql

Copy link
Member

@PeterSurda PeterSurda left a comment

Choose a reason for hiding this comment

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

Just formatting, no moving around functions.

@kdcis kdcis force-pushed the v0.6-codequality-shared branch 4 times, most recently from f49cbf3 to 9a2de11 Compare October 12, 2021 10:14
…ic exception, replaced unicode by decode function changes in shared.py

Replaced unicode by decode function & added UnicodeDecodeError specific exception
@kdcis kdcis force-pushed the v0.6-codequality-shared branch from 9a2de11 to 894e9fc Compare October 13, 2021 07:23
@PeterSurda PeterSurda merged commit 894e9fc into Bitmessage:v0.6 Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

formatting Code or UI text formatting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants