Skip to content

Commit

Permalink
Merge pull request #708 from serokell/krendelhoff/#707-filter-snapshots
Browse files Browse the repository at this point in the history
[#707] Filter snapshots by node's commit hash
  • Loading branch information
pasqu4le authored Sep 5, 2023
2 parents 1640c69 + 3ef9288 commit 567dc9c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion baking/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ description = "Package that provides systemd services that orchestrate other ser
license = { text = "LicenseRef-MIT-OA" }
requires-python = ">=3.8"
readme = "README.md"
version = "v18.0-rc1"
version = "v18.0-rc1a"

[tool.setuptools.packages.find]
where= ["src"]
Expand Down
13 changes: 13 additions & 0 deletions baking/src/tezos_baking/tezos_setup_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ def is_full_snapshot(snapshot_file, import_mode):
return False


def get_node_version_hash():
return get_proc_output("octez-node --version").stdout.decode("ascii").split()[0]


# Steps

network_query = Step(
Expand Down Expand Up @@ -370,13 +374,18 @@ def get_snapshot_link(self):
self.config["snapshot_url"] = None
self.config["snapshot_block_hash"] = None

def hashes_comply(s1, s2):
return s1.startswith(s2) or s2.startswith(s1)

json_url = "https://xtz-shots.io/tezos-snapshots.json"
try:
snapshot_array = None
with urllib.request.urlopen(json_url) as url:
snapshot_array = json.load(url)["data"]
snapshot_array.sort(reverse=True, key=lambda x: x["block_height"])

node_version_hash = get_node_version_hash()

snapshot_metadata = next(
filter(
lambda artifact: artifact["artifact_type"] == "tezos-snapshot"
Expand All @@ -387,6 +396,10 @@ def get_snapshot_link(self):
self.config["history_mode"] == "archive"
and artifact["history_mode"] == "full"
)
)
and hashes_comply(
artifact["tezos_version"]["commit_info"]["commit_hash"],
node_version_hash,
),
iter(snapshot_array),
),
Expand Down
2 changes: 1 addition & 1 deletion docker/package/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ class TezosBakingServicesPackage(AbstractPackage):
# native releases, so we append an extra letter to the version of
# the package.
# This should be reset to "" whenever the native version is bumped.
letter_version = ""
letter_version = "a"

buildfile = "setup.py"

Expand Down
2 changes: 1 addition & 1 deletion meta.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"release": "1",
"release": "2",
"maintainer": "Serokell <[email protected]>",
"tezos_ref": "v18.0-rc1"
}

0 comments on commit 567dc9c

Please sign in to comment.