Skip to content

Conversation

Smlep
Copy link
Contributor

@Smlep Smlep commented Apr 18, 2022

Here is a port of /test/lint/lint-circular-dependencies.sh to a Python-script as part of the request of #24783.

It aims to provide the same output as the bash version.

@Smlep Smlep mentioned this pull request Apr 18, 2022
25 tasks
@brunoerg
Copy link
Contributor

I think you could squash the commits since they're related.

@DrahtBot DrahtBot added the Tests label Apr 19, 2022
@DrahtBot
Copy link
Contributor

DrahtBot commented Apr 19, 2022

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #24230 (indexes: Stop using node internal types and locking cs_main, improve sync logic by ryanofsky)
  • #21726 (Improve Indices on pruned nodes via prune blockers by fjahr)
  • #17786 (refactor: Nuke policy/fees->mempool circular dependencies by hebasto)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@Smlep
Copy link
Contributor Author

Smlep commented Apr 19, 2022

I think you could squash the commits since they're related.

It's done @brunoerg 👍

@KevinMusgrave
Copy link
Contributor

KevinMusgrave commented Apr 19, 2022

Tested 23e0476. The new version could maybe use a line break before the Good job message.

As a test I added:

  • #include <index/coinstatsindex.h> to index/blockfilterindex
  • #include <index/blockfilterindex.h> to index/coinstatsindex

Before (test/lint/lint-circular-dependencies.sh):

A new circular dependency in the form of "index/blockfilterindex -> index/coinstatsindex -> index/blockfilterindex" appears to have been introduced.

A new circular dependency in the form of "index/blockfilterindex -> index/coinstatsindex -> validation -> index/blockfilterindex" appears to have been introduced.

Good job! The circular dependency "index/blockfilterindex -> node/blockstorage -> validation -> index/blockfilterindex" is no longer present.
Please remove it from EXPECTED_CIRCULAR_DEPENDENCIES in test/lint/lint-circular-dependencies.sh
to make sure this circular dependency is not accidentally reintroduced.

After (test/lint/lint-circular-dependencies.py):

A new circular dependency in the form of "index/blockfilterindex -> index/coinstatsindex -> index/blockfilterindex" appears to have been introduced.
A new circular dependency in the form of "index/blockfilterindex -> index/coinstatsindex -> validation -> index/blockfilterindex" appears to have been introduced.
Good job! The circular dependency "index/blockfilterindex -> node/blockstorage -> validation -> index/blockfilterindex" is no longer present.
Please remove it from EXPECTED_CIRCULAR_DEPENDENCIES in test/lint/lint-circular-dependencies.py
to make sure this circular dependency is not accidentally reintroduced.

Sidenote: I'm not sure why adding a circular dependency causes an existing circular dependency to disappear

@Smlep
Copy link
Contributor Author

Smlep commented Apr 19, 2022

@KevinMusgrave Indeed, the newline after each message from the original script was missing.
A new version has been pushed with this fix.

@KevinMusgrave
Copy link
Contributor

Tested ACK ca52afd

Output:

A new circular dependency in the form of "index/blockfilterindex -> index/coinstatsindex -> index/blockfilterindex" appears to have been introduced.

A new circular dependency in the form of "index/blockfilterindex -> index/coinstatsindex -> validation -> index/blockfilterindex" appears to have been introduced.

Good job! The circular dependency "index/blockfilterindex -> node/blockstorage -> validation -> index/blockfilterindex" is no longer present.
Please remove it from EXPECTED_CIRCULAR_DEPENDENCIES in test/lint/lint-circular-dependencies.py
to make sure this circular dependency is not accidentally reintroduced.

Comment on lines +48 to +50
dependencies_output = subprocess.run(
command,
stdout=subprocess.PIPE,
Copy link
Member

Choose a reason for hiding this comment

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

any reason to ignore errors?

Suggested change
dependencies_output = subprocess.run(
command,
stdout=subprocess.PIPE,
dependencies_output = subprocess.check_output(
command,

Copy link
Contributor Author

@Smlep Smlep Apr 20, 2022

Choose a reason for hiding this comment

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

Because ../contrib/devtools/circular-dependencies.py does not exit with 0 if there is at least one circular dependency, resulting in subprocess.check raising an error

@laanwj
Copy link
Member

laanwj commented Apr 25, 2022

Tested ACK 79635c7

@laanwj laanwj merged commit 16fa967 into bitcoin:master Apr 25, 2022

# Using glob.glob since subprocess.run's globbing won't work without shell=True
files = []
for path in ["*", "*/*", "*/*/*"]:
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it be better to call git ls-files -- '*.h' '*.cpp'?

for extension in ["h", "cpp"]:
files.extend(glob.glob(f"{path}.{extension}"))

command = ["python3", "../contrib/devtools/circular-dependencies.py", *files]
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it be better to use sys.executable instead of "python3"?

sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Apr 26, 2022
…ython

79635c7 lint: Convert lint-circular-dependencies.sh to Python (Smlep)

Pull request description:

  Here is a port of `/test/lint/lint-circular-dependencies.sh` to a Python-script as part of the request of bitcoin#24783.

  It aims to provide the same output as the bash version.

ACKs for top commit:
  laanwj:
    Tested ACK 79635c7

Tree-SHA512: f18077018f1229dd933cfe2bf0cfe7dc7d6538961c96a83c7a1f05e0cec4b068ca05502d68410d2aa4b6864523424db386e38233735190525904c2a8e9d2ba13
@bitcoin bitcoin locked and limited conversation to collaborators Apr 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants