-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmain.star
99 lines (84 loc) · 4.1 KB
/
main.star
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
validator = import_module("./validator.star")
relayer = import_module("./relayer.star")
utils = import_module("./utils.star")
def run(
plan,
origin_chain_name,
validator_key,
agent_config_json,
relay_chains,
rpc_urls={},
custom_validator_image="gcr.io/abacus-labs-dev/hyperlane-agent:a888cf7-20231214-180118",
custom_relayer_image="gcr.io/abacus-labs-dev/hyperlane-agent:a888cf7-20231214-180118",
log_level="info",
aws_access_key_id="",
aws_secret_access_key="",
aws_bucket_region="",
aws_bucket_name="",
aws_bucket_folder="",
):
"""Runs a Hyperlane validator and relayer
Args:
origin_chain_name (string): The name of the origin chain
origin_chain_url (string): The RPC url of the origin chain
validator_key (string): The private key (0x-prefixed) to be used by the validator
relay_chains (string): comma separated list of chains to relay between
agent_config_json: The agent config used by Hyperlane validator and relayer
rpc_urls (dict[string, string]): Mapping of chainName => rpcURL
custom_validator_image (string): A custom image to use to run the validator
custom_relayer_image (string): A custom image to use to run the relayer
log_level (string): Custom logging level. Defaults to "info"
aws_access_key_id (string): A custom AWS access key ID to use for accessing the AWS bucket
aws_secret_access_key (string): A custom AWS secret access key to use for accessing the AWS bucket
aws_bucket_region (string): The region of the custom bucket to be used
aws_bucket_name (string): The name of the custom bucket to be used
aws_bucket_folder (string): The folder inside the bucket to use
"""
aws_env = {}
if len(aws_access_key_id) > 0:
aws_env["aws_access_key_id"] = aws_access_key_id
if len(aws_secret_access_key) > 0:
aws_env["aws_secret_access_key"] = aws_secret_access_key
if len(aws_bucket_region) > 0:
aws_env["aws_bucket_region"] = aws_bucket_region
if len(aws_bucket_name) > 0:
aws_env["aws_bucket_name"] = aws_bucket_name
if len(aws_bucket_folder) > 0:
aws_env["aws_bucket_user_folder"] = aws_bucket_folder
relay_chains = [chain.strip() for chain in relay_chains.split(',')]
if len(relay_chains) < 2:
fail("At least two chains must be provided to relay between")
if len(validator_key) < 64:
fail("Invalid validator key provided")
validator_key = validator_key if validator_key.startswith("0x") else "0x" + validator_key
env_aws = get_aws_user_info(plan, aws_env)
origin_chain = {
"chain_name": origin_chain_name,
"signer_id": validator_key,
}
# ONCE THE BUG IS FIXED, I WILL REMOVE THIS
if log_level == "":
log_level = "info"
# ADD DEPLOY STEP HERE
config_file = utils.get_agent_config_artifact(plan, agent_config_json)
validator.run(plan, config_file, origin_chain, rpc_urls, env_aws, custom_validator_image, log_level)
relayer.run(plan, config_file, relay_chains, validator_key, rpc_urls, env_aws, custom_relayer_image, log_level)
def get_aws_user_info(plan, aws_env):
if len(aws_env) > 0:
# use this instead of potential values passed via the `kurtosis` module
return struct(
access_key_id=aws_env["aws_access_key_id"],
secret_access_key=aws_env["aws_secret_access_key"],
bucket_region=aws_env["aws_bucket_region"],
bucket_name=aws_env["aws_bucket_name"],
bucket_user_folder=aws_env["aws_bucket_user_folder"] if "aws_bucket_user_folder" in aws_env else ""
)
else:
# the AWS values should be provided as env variables to the package. Otherwise this package cannot run
return struct(
access_key_id=kurtosis.aws_access_key_id,
secret_access_key=kurtosis.aws_secret_access_key,
bucket_region=kurtosis.aws_bucket_region,
bucket_name=kurtosis.aws_bucket_name,
bucket_user_folder=kurtosis.aws_bucket_user_folder
)