-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
contrib: Add asmap-tool #28793
contrib: Add asmap-tool #28793
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
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. |
2f7db67
to
14ff893
Compare
14ff893
to
fde0193
Compare
Concept ACK |
contrib/asmap/asmap-tool.py
Outdated
|
||
import asmap | ||
|
||
def load_file(input_file, state=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fde0193: Is there any case of state
not being None
for any load_file
usage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not right now; we could drop that for now. I think the idea was supporting loading an asmap, and then also loading a patch file on top of it (which could be created by diffing).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropped it for now
Concept NACK
That's not a reason. Ideally, the current repo should be split into several itself - but we have technical hurdles to get to that point. No reason to add more here "just because" |
I'm fine with adding another contrib script here. But we could also make a new repo under bitcoin-core. Perhaps the choice depends on whether this tool is mainly useful for users, developers or maintainers (bitcoin-core/bitcoin-maintainer-tools)? |
@luke-jr It is a reason, but you don't have to agree with it ;) If we want to move the
@Sjors All of the above. Users who want to build and use their own asmap file need to encode it for bitcoin core to accept it. Developers who want to test asmap functionality will need to encode and possibly also decode asmap files. Maintainers who build a release including an asmap file will need to encode the file as well if they want to reproduce the asmap file that will be embedded. |
980e2a3
to
423dbf8
Compare
423dbf8
to
a86ffab
Compare
Concept ACK on just adding these 150 lines of Python here, and lower the barrier for people to verify these things. There's still some work in progress on fixing determinism, see fjahr/asmap-data#6, but getting close! |
47d4339
to
66620b9
Compare
This should be fixed now, the issue appears to have been the ordering of sets after combining/diffing them. The results are now explicitly sorted. On my system, I could replicate the issue by using different python versions and it was fixed with this change. Credits to @sipa for pointing me in the right direction. |
66620b9
to
798ff1d
Compare
asmap_dir = Path(__file__).parent.parent / "asmap" | ||
sys.path.append(str(asmap_dir)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I searched other scripts in contrib
for appending to sys.path
to find out if there's precedent one could follow:
testgen/gen_key_io_test_vectors.py
14:sys.path.append(os.path.join(os.path.dirname(__file__), '../../test/functional')
message-capture/message-capture-parser.py
16:sys.path.append(os.path.join(os.path.dirname(__file__), '../../test/functional'))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this hint but I think usage of pathlib
is usually preferred now because it is more modern. So I will keep this as is unless there are more pros to this change that I have overlooked.
798ff1d
to
856a2da
Compare
Addressed comments from @virtu , thanks for reviewing! |
Co-authored-by: Pieter Wuille <pieter@wuille.net>
856a2da
to
6abe772
Compare
🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the Possibly this is due to a silent merge conflict (the changes in this pull request being Leave a comment here, if you need help tracking down a confusing failure. |
ACK 6abe772 Tested decoding and encoding some demo ASMaps. Also made sure encoding yields a reproducible ordering by decoding, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 6abe772
I've been using this for a while but did some new tests to ensure.
I've tested encoding/decoding as well as the diff command with a very old file (1 year ago) and a newest one to test big changes - e.g.: # 1296418840 (2^30.27) IPv4 addresses changed; 8741211000446919691919144517632603 (2^112.75) IPv6 addresses changed).
. I think code could be clearer but lgtm to merge as is.
ACK 6abe772 Did some light code review & some testing of I don't have a particular strong opinion on having this here or e.g. a bitcoin-core repository. |
ACK 6abe772 |
This adds
asmap.py
andasmap-tool.py
from sipa'snextgen
branch: https://github.com/sipa/asmap/tree/nextgenThe motivation is that we should maintain the tooling for de- and encoding asmap files within the bitcoin core repository because it is not possible to use an asmap file that is not encoded.
We already had an earlier version of
asmap.py
within the seeds contrib tools. The newer version only had a small amount of changes and is still compatible, so the old version is removed from contrib/seeds and the new version is made available tomakeseeds.py
.