Page MenuHomePhabricator

[electrum] move checkpoint data to a json file
ClosedPublic

Authored by PiRK on Dec 14 2023, 13:52.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC716ae6a36889: [electrum] move checkpoint data to a json file
Summary

And add an option to the get_merkle_root script to output the file in the correct format.

This will make it easier to automate the checkpoint updating without using hacky way to modify the networks.py source file.

Depends on D14981

Test Plan

The two json files in this diff were generated via:

scripts/get_merkle_root 822000 --json-output electrumabc/checkpoint.json
scripts/get_merkle_root 1477500 --json-output electrumabc/checkpoint_testnet.json  --server telectrum.bitcoinabc.org:60002:s

Run the software, check that we are connected, that the servers are not blacklisted (would happen if the merkle root was wrong).

Build some release binaries and test them, to make sure the new data files are properly packaged.

Diff Detail

Repository
rABC Bitcoin ABC
Branch
checkpoints_automation
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 25962
Build 51499: Build Diffelectrum-tests
Build 51498: arc lint + arc unit

Event Timeline

PiRK requested review of this revision.Dec 14 2023, 13:52
PiRK planned changes to this revision.Dec 14 2023, 13:53

Let's also build an AppImage release and check that the file are correctly included.

remove unrelated newline change

Fabien requested changes to this revision.Dec 14 2023, 19:10
Fabien added a subscriber: Fabien.
Fabien added inline comments.
electrum/electrumabc/checkpoint.json
1 ↗(On Diff #43617)

why is that an array and not an object ?

electrum/scripts/get_merkle_root
135 ↗(On Diff #43617)

That would make more sense to me

This revision now requires changes to proceed.Dec 14 2023, 19:10
electrum/scripts/get_merkle_root
135 ↗(On Diff #43617)

It would be a bit more verbose to unpack the data in networks.py, and the dict makes me feel like there could be more than one checkpoint in the file (so we'll need additional code to check len(_read_json( "checkpoint.json")) == 1`)
But no strong opinion on that, I can change it.

electrum/scripts/get_merkle_root
135 ↗(On Diff #43617)

An array is clearly a way to express there could be more than 1 element, so imo it's rather the opposite

electrum/scripts/get_merkle_root
135 ↗(On Diff #43617)

Actually it is possible to unpack a dict with a single item in a single-liner, so no objection
[(k, v)] = d.items() or (k, v), = d.items()

What I meant is that unpacking a list clearly raises an error if the number of elements does not match the expected number, and I thought that this wasn't possible with dicts without additional verbose checks, but apparently it is.

electrum/scripts/get_merkle_root
135 ↗(On Diff #43617)

I forgot that you can only use strings as the key in JSON. So it will have to be something like:
json.dump({"height": checkpoint, "merkle_root": merkle_root})

This revision is now accepted and ready to land.Dec 15 2023, 08:51
This revision was automatically updated to reflect the committed changes.