Skip to content
This repository was archived by the owner on May 29, 2025. It is now read-only.

Commit 1af3242

Browse files
Merge pull request #271 from valory-xyz/develop
Release v0.14.2
2 parents 6e940a5 + 7a58bba commit 1af3242

File tree

4 files changed

+76
-40
lines changed

4 files changed

+76
-40
lines changed

report.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
OPERATOR_KEYS_JSON_PATH = Path(STORE_PATH, "operator_keys.json")
5252
SAFE_ADDRESS_PATH = Path(STORE_PATH, "service_safe_address.txt")
5353
SERVICE_ID_PATH = Path(STORE_PATH, "service_id.txt")
54-
SERVICE_STAKING_CONTRACT_ADDRESS = "0x2Ef503950Be67a98746F484DA0bBAdA339DF3326"
54+
SERVICE_STAKING_CONTRACT_ADDRESS = "0x43fB32f25dce34EB76c78C7A42C8F40F84BCD237"
5555
SERVICE_STAKING_TOKEN_JSON_PATH = Path(
5656
SCRIPT_PATH,
5757
"trader",

run_service.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ export RPC_RETRIES=40
596596
export RPC_TIMEOUT_SECONDS=120
597597
export CUSTOM_SERVICE_MANAGER_ADDRESS="0x04b0007b2aFb398015B76e5f22993a1fddF83644"
598598
export CUSTOM_SERVICE_REGISTRY_ADDRESS="0x9338b5153AE39BB89f50468E608eD9d764B755fD"
599-
export CUSTOM_STAKING_ADDRESS="0x2Ef503950Be67a98746F484DA0bBAdA339DF3326"
599+
export CUSTOM_STAKING_ADDRESS="0x43fB32f25dce34EB76c78C7A42C8F40F84BCD237"
600600
export CUSTOM_OLAS_ADDRESS="0xcE11e14225575945b8E6Dc0D4F2dD4C570f79d9f"
601601
export CUSTOM_SERVICE_REGISTRY_TOKEN_UTILITY_ADDRESS="0xa45E64d13A30a51b91ae0eb182e88a40e9b18eD8"
602602
export CUSTOM_GNOSIS_SAFE_PROXY_FACTORY_ADDRESS="0x3C1fF68f5aa342D296d4DEe4Bb1cACCA912D95fE"
@@ -1064,7 +1064,7 @@ export OMEN_CREATORS='["0x89c5cc945dd550BcFfb72Fe42BfF002429F46Fec"]'
10641064
export BET_THRESHOLD=100000000000000000
10651065
export TRADING_STRATEGY=kelly_criterion
10661066
export PROMPT_TEMPLATE="Please take over the role of a Data Scientist to evaluate the given question. With the given question \"@{question}\" and the \`yes\` option represented by \`@{yes}\` and the \`no\` option represented by \`@{no}\`, what are the respective probabilities of \`p_yes\` and \`p_no\` occurring?"
1067-
export IRRELEVANT_TOOLS='["prediction-offline-sme", "openai-gpt-3.5-turbo-instruct", "prediction-online-summarized-info", "prediction-online-sum-url-content", "prediction-online", "openai-text-davinci-002", "openai-text-davinci-003", "openai-gpt-3.5-turbo", "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", "stabilityai-stable-diffusion-xl-beta-v2-2-2", "stabilityai-stable-diffusion-512-v2-1", "stabilityai-stable-diffusion-768-v2-1", "deepmind-optimization-strong", "deepmind-optimization", "claude-prediction-offline"]'
1067+
export IRRELEVANT_TOOLS='["claude-prediction-online","prediction-request-reasoning","prediction-online","prediction-offline","prediction-offline-sme","deepmind-optimization", "deepmind-optimization-strong", "openai-gpt-3.5-turbo", "openai-gpt-3.5-turbo-instruct", "openai-gpt-4", "openai-text-davinci-002", "openai-text-davinci-003", "prediction-online-sum-url-content", "prediction-online-summarized-info", "stabilityai-stable-diffusion-512-v2-1", "stabilityai-stable-diffusion-768-v2-1", "stabilityai-stable-diffusion-v1-5", "stabilityai-stable-diffusion-xl-beta-v2-2-2"]'
10681068

10691069
service_dir="trader_service"
10701070
build_dir="abci_build"

scripts/staking.py

Lines changed: 72 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@
4545
)
4646

4747

48-
OLD_STAKING_PROGRAMS = {"Everest": "0x5add592ce0a1B5DceCebB5Dcac086Cd9F9e3eA5C"}
48+
OLD_STAKING_PROGRAMS = {
49+
"Everest": "0x5add592ce0a1B5DceCebB5Dcac086Cd9F9e3eA5C",
50+
"Alpine": "0x2Ef503950Be67a98746F484DA0bBAdA339DF3326"
51+
}
4952

5053

5154
def _format_duration(duration_seconds: int) -> str:
@@ -56,7 +59,7 @@ def _format_duration(duration_seconds: int) -> str:
5659
return formatted_duration
5760

5861

59-
def _unstake(
62+
def _unstake_old_program(
6063
ledger_api: EthereumApi,
6164
service_id: int,
6265
staking_contract_address: str,
@@ -72,16 +75,34 @@ def _unstake(
7275
return
7376
elif staking_program.startswith("Alpine"):
7477
if not is_service_staked(
75-
ledger_api, args.service_id, args.staking_contract_address
78+
ledger_api, service_id, staking_contract_address
7679
):
77-
print(f"Service {args.service_id} is not staked on {staking_program}..")
80+
print(f"Service {service_id} is not staked on {staking_program}..")
7881
return
7982

83+
can_unstake = _check_unstaking_availability(
84+
ledger_api,
85+
service_id,
86+
staking_contract_address,
87+
staking_program,
88+
)
89+
if not can_unstake:
90+
print(
91+
"\n"
92+
"WARNING: Service cannot be unstaked yet\n"
93+
"---------------------------------------\n"
94+
f"Service {service_id} cannot be unstaked from {staking_program} at this time.\n"
95+
f"You can still run your service, but it will stay staked in {staking_program}.\n"
96+
"Please, try re-running this script again at a later time to try stake on a new program.\n"
97+
)
98+
input("Press Enter to continue...")
99+
sys.exit(0)
100+
80101
print(
81102
f"Service {service_id} is staked on {staking_program}. To continue in a new staking program, first, it must be unstaked from {staking_program}."
82103
)
83104
user_input = input(
84-
"Do you want to continue unstaking from {staking_program}? (yes/no)\n"
105+
f"Do you want to continue unstaking service {service_id} from {staking_program}? (yes/no)\n"
85106
).lower()
86107
print()
87108

@@ -93,32 +114,42 @@ def _unstake(
93114
unstake_txs = get_unstake_txs(ledger_api, service_id, staking_contract_address)
94115
for tx in unstake_txs:
95116
send_tx_and_wait_for_receipt(ledger_api, owner_crypto, tx)
96-
print(f"Successfully unstaked service {args.service_id} from {staking_program}.")
117+
print(f"Successfully unstaked service {service_id} from {staking_program}.")
97118

98119

99-
def _unstake_old_programs(
120+
def _unstake_all_old_programs(
100121
ledger_api: EthereumApi, service_id: int, owner_crypto: EthereumCrypto
101122
) -> None:
123+
print("Unstaking from old programs...")
102124
for program, address in OLD_STAKING_PROGRAMS.items():
103-
_unstake(ledger_api, service_id, address, program, owner_crypto)
125+
_unstake_old_program(ledger_api, service_id, address, program, owner_crypto)
104126

105127

106128
def _check_unstaking_availability(
107-
now: float,
108-
ts_start: float,
109-
minimum_staking_duration: int,
110-
available_rewards: float,
129+
ledger_api: EthereumApi,
130+
service_id: int,
131+
staking_contract_address: str,
111132
staking_program: str,
112-
) -> None:
133+
) -> bool:
134+
135+
now = time.time()
136+
ts_start = get_service_info(
137+
ledger_api, service_id, staking_contract_address
138+
)[3]
139+
minimum_staking_duration = get_min_staking_duration(
140+
ledger_api, staking_contract_address
141+
)
142+
available_rewards = get_available_rewards(ledger_api, staking_contract_address)
113143
if (now - ts_start) < minimum_staking_duration and available_rewards > 0:
114144
print(
115145
f"WARNING: Your service has been staked on {staking_program} for {_format_duration(int(now - ts_start))}."
116146
)
117147
print(
118148
f"You cannot unstake your service from {staking_program} until it has been staked for at least {_format_duration(minimum_staking_duration)}."
119149
)
120-
print("Terminating script.")
121-
sys.exit(1)
150+
return False
151+
152+
return True
122153

123154

124155
def _try_stake_service(
@@ -127,6 +158,7 @@ def _try_stake_service(
127158
owner_crypto: EthereumCrypto,
128159
service_registry_address: str,
129160
staking_contract_address: str,
161+
staking_program: str,
130162
) -> None:
131163
if get_available_staking_slots(ledger_api, staking_contract_address) > 0:
132164
print(
@@ -160,9 +192,9 @@ def _try_stake_service(
160192
sys.exit(1)
161193

162194

163-
if __name__ == "__main__":
195+
def main() -> None:
164196
try:
165-
staking_program = "Alpine"
197+
staking_program = "Coastal"
166198
print(f"Starting {Path(__file__).name} script ({staking_program})...\n")
167199

168200
parser = argparse.ArgumentParser(
@@ -202,21 +234,13 @@ def _try_stake_service(
202234
private_key_path=args.owner_private_key_path, password=args.password
203235
)
204236

205-
_unstake_old_programs(ledger_api, args.service_id, owner_crypto)
237+
_unstake_all_old_programs(ledger_api, args.service_id, owner_crypto)
206238

207239
# Collect information
208240
next_ts = get_next_checkpoint_ts(ledger_api, args.staking_contract_address)
209-
ts_start = get_service_info(
210-
ledger_api, args.service_id, args.staking_contract_address
211-
)[3]
212-
213241
liveness_period = get_liveness_period(ledger_api, args.staking_contract_address)
214242
last_ts = next_ts - liveness_period
215243
now = time.time()
216-
217-
minimum_staking_duration = get_min_staking_duration(
218-
ledger_api, args.staking_contract_address
219-
)
220244
available_rewards = get_available_rewards(
221245
ledger_api, args.staking_contract_address
222246
)
@@ -237,14 +261,17 @@ def _try_stake_service(
237261
)
238262
input("Press Enter to continue...")
239263

240-
_check_unstaking_availability(
241-
now,
242-
ts_start,
243-
minimum_staking_duration,
244-
available_rewards,
264+
can_unstake = _check_unstaking_availability(
265+
ledger_api,
266+
args.service_id,
267+
args.staking_contract_address,
245268
staking_program,
246269
)
247270

271+
if not can_unstake:
272+
print("Terminating script.")
273+
sys.exit(1)
274+
248275
if now < next_ts:
249276
formatted_last_ts = datetime.utcfromtimestamp(last_ts).strftime(
250277
"%Y-%m-%d %H:%M:%S UTC"
@@ -294,14 +321,17 @@ def _try_stake_service(
294321
f"Service {args.service_id} has been evicted from the {staking_program} staking program due to inactivity. Unstaking..."
295322
)
296323

297-
_check_unstaking_availability(
298-
now,
299-
ts_start,
300-
minimum_staking_duration,
301-
available_rewards,
324+
can_unstake = _check_unstaking_availability(
325+
ledger_api,
326+
args.service_id,
327+
args.staking_contract_address,
302328
staking_program,
303329
)
304330

331+
if not can_unstake:
332+
print("Terminating script.")
333+
sys.exit(1)
334+
305335
unstake_txs = get_unstake_txs(
306336
ledger_api, args.service_id, args.staking_contract_address
307337
)
@@ -318,6 +348,7 @@ def _try_stake_service(
318348
owner_crypto=owner_crypto,
319349
service_registry_address=args.service_registry_address,
320350
staking_contract_address=args.staking_contract_address,
351+
staking_program=staking_program,
321352
)
322353
sys.exit(0)
323354

@@ -354,6 +385,7 @@ def _try_stake_service(
354385
owner_crypto=owner_crypto,
355386
service_registry_address=args.service_registry_address,
356387
staking_contract_address=args.staking_contract_address,
388+
staking_program=staking_program,
357389
)
358390

359391
except Exception as e: # pylint: disable=broad-except
@@ -364,3 +396,7 @@ def _try_stake_service(
364396
"\nPlease confirm whether your service is participating in a staking program, and then retry running the script."
365397
)
366398
sys.exit(1)
399+
400+
401+
if __name__ == "__main__":
402+
main()

terminate_on_chain_service.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export CUSTOM_CHAIN_RPC=$rpc
121121
export CUSTOM_CHAIN_ID=$gnosis_chain_id
122122
export CUSTOM_SERVICE_MANAGER_ADDRESS="0x04b0007b2aFb398015B76e5f22993a1fddF83644"
123123
export CUSTOM_SERVICE_REGISTRY_ADDRESS="0x9338b5153AE39BB89f50468E608eD9d764B755fD"
124-
export CUSTOM_STAKING_ADDRESS="0x2Ef503950Be67a98746F484DA0bBAdA339DF3326"
124+
export CUSTOM_STAKING_ADDRESS="0x43fB32f25dce34EB76c78C7A42C8F40F84BCD237"
125125
export CUSTOM_OLAS_ADDRESS="0xcE11e14225575945b8E6Dc0D4F2dD4C570f79d9f"
126126
export CUSTOM_SERVICE_REGISTRY_TOKEN_UTILITY_ADDRESS="0xa45E64d13A30a51b91ae0eb182e88a40e9b18eD8"
127127
export CUSTOM_GNOSIS_SAFE_PROXY_FACTORY_ADDRESS="0x3C1fF68f5aa342D296d4DEe4Bb1cACCA912D95fE"

0 commit comments

Comments
 (0)