forked from aptos-labs/aptos-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
module_verify.py
executable file
·58 lines (47 loc) · 1.7 KB
/
module_verify.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
# Copyright © Aptos Foundation
# SPDX-License-Identifier: Apache-2.0
import os
import shutil
import subprocess
from verify_core.common import query_backup_latest_version, clear_artifacts
def main():
# collect all required ENV variables
REQUIRED_ENVS = [
"BUCKET",
"SUB_DIR",
"BACKUP_CONFIG_TEMPLATE_PATH",
]
if not all(env in os.environ for env in REQUIRED_ENVS):
raise Exception("Missing required ENV variables")
BACKUP_CONFIG_TEMPLATE_PATH = os.environ["BACKUP_CONFIG_TEMPLATE_PATH"]
if not os.path.exists(BACKUP_CONFIG_TEMPLATE_PATH):
raise Exception("BACKUP_CONFIG_TEMPLATE_PATH does not exist")
with open(BACKUP_CONFIG_TEMPLATE_PATH, "r") as f:
config = f.read()
if "aws" in config and shutil.which("aws") is None:
raise Exception("Missing required AWS CLI for pulling backup data from S3")
if os.environ.get("REUSE_BACKUP_ARTIFACTS", "true") == "true":
print("[main process] clearing existing backup artifacts")
clear_artifacts()
else:
print("[main process] skipping clearing backup artifacts")
# run verify-modules
os.mkdir("local")
subprocess.run(
[
"target/release/aptos-debugger",
"aptos-db",
"backup",
"verify",
"--validate-modules",
"--concurrent-downloads=16",
"--metadata-cache-dir=./local/metadata-cache",
"--start-version=max", # to disable transaction verification
"--skip-epoch-endings",
"--command-adapter-config",
f"{BACKUP_CONFIG_TEMPLATE_PATH}",
]
)
if __name__ == "__main__":
main()