Skip to content

Commit

Permalink
Merge pull request #298 from valory-xyz/v0.16.5
Browse files Browse the repository at this point in the history
[v0.16.5]: Reschedule changes for the next release
  • Loading branch information
Adamantios authored Jul 19, 2024
2 parents f4607e7 + 3cfb8ce commit b0d3524
Show file tree
Hide file tree
Showing 25 changed files with 490 additions and 485 deletions.
12 changes: 6 additions & 6 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
"contract/valory/staking_token/0.1.0": "bafybeig4fl35dn7d5gnprux2nwsqbirm7zkiujz3xvrwcjuktz6hkq4as4",
"contract/valory/relayer/0.1.0": "bafybeihzgjyvhtorugjw3yldznqsbwo3aqpxowm7k2nrvj6qtwpsc7jl7u",
"skill/valory/market_manager_abci/0.1.0": "bafybeig44vtxcq7aarqkg2mskly3zwwnyfc45rtdvorwz6ywspwg3obqn4",
"skill/valory/decision_maker_abci/0.1.0": "bafybeiejbfkl4im6srigta53ysan3tu5hlbb44cbd2mgryp2hsanyxpdge",
"skill/valory/trader_abci/0.1.0": "bafybeigfccxw5v76pectrmh2a3ibd4gt2hhtskkqay6an3g7lgdyotuz34",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeiaiek6b3p7dro45qjoecmgseznhixhrgqgxfiap7lqw4rbi5fyhvy",
"skill/valory/decision_maker_abci/0.1.0": "bafybeiapszwgdpq6ipu5ffjgzi3r7ylyuaju6n26xalclnnixnzprnynuu",
"skill/valory/trader_abci/0.1.0": "bafybeidvlov6ktapczwfeipyaalakbvb4eqcw6brctxzp6hqplf2pfpr7a",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeiggsvl7zxifj3haydd4njb3griljqpr4wledvqi3gh2lvcbbphxdq",
"skill/valory/staking_abci/0.1.0": "bafybeidubhfvlf6x627t4wetc6ran5sb4pttjphyhv6vefp2a4kcuca2be",
"skill/valory/check_stop_trading_abci/0.1.0": "bafybeiboctfgetji6xlzw2buts5zsejnlrrhqkppme2p6fwzu26zznb324",
"agent/valory/trader/0.1.0": "bafybeiaxm4ts4odvhmbltyaa7rngm6jio7b4fdwvwszahw2ndfjdpd547a",
"service/valory/trader/0.1.0": "bafybeig3dk2wuzspnu7aeop2wbxd7sfe5yjlsj3yreen6v6vrtqwj4htyq",
"service/valory/trader_pearl/0.1.0": "bafybeicnm3uxoo7xfotbuhiafqalhfai2etkj5pqha6v4gejy4ilg5lcom"
"agent/valory/trader/0.1.0": "bafybeicpf66igauitqbhnt24scqrmlxfu6ervkfyq2tucejxxz33f2rbtu",
"service/valory/trader/0.1.0": "bafybeifkkqoxce4gjueffcuhmwpu76r7oynfxzonphy4dr5euk6r6fkwhe",
"service/valory/trader_pearl/0.1.0": "bafybeibf6w4xnjii2nbzvsykmes3rreedogvmiggl2ih7djis4fzkhaodu"
},
"third_party": {
"protocol/open_aea/signing/1.0.0": "bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi",
Expand Down
13 changes: 3 additions & 10 deletions packages/valory/agents/trader/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ skills:
- valory/reset_pause_abci:0.1.0:bafybeiameewywqigpupy3u2iwnkfczeiiucue74x2l5lbge74rmw6bgaie
- valory/termination_abci:0.1.0:bafybeif2zim2de356eo3sipkmoev5emwadpqqzk3huwqarywh4tmqt3vzq
- valory/transaction_settlement_abci:0.1.0:bafybeic3tccdjypuge2lewtlgprwkbb53lhgsgn7oiwzyrcrrptrbeyote
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiaiek6b3p7dro45qjoecmgseznhixhrgqgxfiap7lqw4rbi5fyhvy
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiggsvl7zxifj3haydd4njb3griljqpr4wledvqi3gh2lvcbbphxdq
- valory/market_manager_abci:0.1.0:bafybeig44vtxcq7aarqkg2mskly3zwwnyfc45rtdvorwz6ywspwg3obqn4
- valory/decision_maker_abci:0.1.0:bafybeiejbfkl4im6srigta53ysan3tu5hlbb44cbd2mgryp2hsanyxpdge
- valory/trader_abci:0.1.0:bafybeigfccxw5v76pectrmh2a3ibd4gt2hhtskkqay6an3g7lgdyotuz34
- valory/decision_maker_abci:0.1.0:bafybeiapszwgdpq6ipu5ffjgzi3r7ylyuaju6n26xalclnnixnzprnynuu
- valory/trader_abci:0.1.0:bafybeidvlov6ktapczwfeipyaalakbvb4eqcw6brctxzp6hqplf2pfpr7a
- valory/staking_abci:0.1.0:bafybeidubhfvlf6x627t4wetc6ran5sb4pttjphyhv6vefp2a4kcuca2be
- valory/check_stop_trading_abci:0.1.0:bafybeiboctfgetji6xlzw2buts5zsejnlrrhqkppme2p6fwzu26zznb324
- valory/mech_interact_abci:0.1.0:bafybeih2cck5xu6yaibomwtm5zbcp6llghr3ighdnk56fzwu3ihu5xx35e
Expand Down Expand Up @@ -192,7 +192,6 @@ models:
bet_threshold: ${int:100000000000000000}
blacklisting_duration: ${int:3600}
ipfs_address: ${str:https://gateway.autonolas.tech/ipfs/}
tools_accuracy_hash: ${str:QmR8etyW3TPFadNtNrW54vfnFqmh8vBrMARWV76EmxCZyk}
prompt_template: ${str: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?}
Expand Down Expand Up @@ -258,12 +257,6 @@ models:
bet_amount_field: ${str:collateral_amount}
results_filename: ${str:benchmarking_results.csv}
randomness: ${str:benchmarking_randomness}
acc_info_fields:
args:
tool: ${str:tool}
requests: ${str:total_requests}
accuracy: ${str:tool_accuracy}
sep: ${str:,}
network_subgraph:
args:
headers:
Expand Down
76 changes: 33 additions & 43 deletions packages/valory/services/trader/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license: Apache-2.0
fingerprint:
README.md: bafybeigtuothskwyvrhfosps2bu6suauycolj67dpuxqvnicdrdu7yhtvq
fingerprint_ignore_patterns: []
agent: valory/trader:0.1.0:bafybeiaxm4ts4odvhmbltyaa7rngm6jio7b4fdwvwszahw2ndfjdpd547a
agent: valory/trader:0.1.0:bafybeicpf66igauitqbhnt24scqrmlxfu6ervkfyq2tucejxxz33f2rbtu
number_of_agents: 4
deployment:
agent:
Expand Down Expand Up @@ -97,7 +97,6 @@ type: skill
bet_threshold: ${BET_THRESHOLD:int:100000000000000000}
blacklisting_duration: ${BLACKLISTING_DURATION:int:3600}
ipfs_address: ${IPFS_ADDRESS:str:https://gateway.autonolas.tech/ipfs/}
tools_accuracy_hash: ${TOOLS_ACCURACY_HASH:str:QmR8etyW3TPFadNtNrW54vfnFqmh8vBrMARWV76EmxCZyk}
prompt_template: ${PROMPT_TEMPLATE:str: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`
Expand Down Expand Up @@ -167,13 +166,7 @@ type: skill
bet_amount_field: ${BENCHMARKING_MODE_BET_AMOUNT_FIELD:str:collateral_amount}
results_filename: ${BENCHMARKING_MODE_RESULTS_FILENAME:str:benchmarking_results.csv}
randomness: ${BENCHMARKING_MODE_RANDOMNESS:str:benchmarking_randomness}
acc_info_fields: &id005
args:
tool: ${ACC_INFO_FIELDS_TOOL:str:tool}
requests: ${ACC_INFO_FIELDS_REQUESTS:str:total_requests}
accuracy: ${ACC_INFO_FIELDS_ACCURACY:str:tool_accuracy}
sep: ${ACC_INFO_FIELDS_SEP:str:,}
network_subgraph: &id006
network_subgraph: &id005
args:
headers:
Content-Type: ${NETWORK_SUBGRAPH_CONTENT_TYPE:str:application/json}
Expand All @@ -186,7 +179,7 @@ type: skill
error_type: ${NETWORK_SUBGRAPH_ERROR_TYPE:str:dict}
retries: ${NETWORK_SUBGRAPH_RETRIES:int:5}
url: ${NETWORK_SUBGRAPH_URL:str:https://api.thegraph.com/subgraphs/name/stakewise/ethereum-gnosis}
omen_subgraph: &id007
omen_subgraph: &id006
args:
headers:
Content-Type: ${OMEN_SUBGRAPH_CONTENT_TYPE:str:application/json}
Expand All @@ -198,14 +191,14 @@ type: skill
error_type: ${NETWORK_SUBGRAPH_ERROR_TYPE:str:dict}
retries: ${OMEN_SUBGRAPH_RETRIES:int:5}
url: ${OMEN_SUBGRAPH_URL:str:https://api.thegraph.com/subgraphs/name/protofire/omen-xdai}
randomness_api: &id008
randomness_api: &id007
args:
method: ${RANDOMNESS_API_METHOD:str:GET}
response_key: ${RANDOMNESS_API_RESPONSE_KEY:str:null}
response_type: ${RANDOMNESS_API_RESPONSE_TYPE:str:dict}
retries: ${RANDOMNESS_API_RETRIES:int:5}
url: ${RANDOMNESS_API_URL:str:https://drand.cloudflare.com/public/latest}
mech_response: &id009
mech_response: &id008
args:
headers:
Content-Type: ${MECH_RESPONSE_API_CONTENT_TYPE:str:application/json}
Expand All @@ -214,7 +207,7 @@ type: skill
response_type: ${MECH_RESPONSE_API_RESPONSE_TYPE:str:str}
retries: ${MECH_RESPONSE_API_RETRIES:int:5}
url: ${MECH_RESPONSE_API_URL:str:''}
agent_tools: &id010
agent_tools: &id009
args:
headers:
Content-Type: ${AGENT_TOOLS_API_CONTENT_TYPE:str:application/json}
Expand All @@ -223,7 +216,7 @@ type: skill
response_type: ${AGENT_TOOLS_API_RESPONSE_TYPE:str:list}
retries: ${AGENT_TOOLS_API_RETRIES:int:5}
url: ${AGENT_TOOLS_API_URL:str:''}
trades_subgraph: &id011
trades_subgraph: &id010
args:
headers:
Content-Type: ${TRADES_SUBGRAPH_CONTENT_TYPE:str:application/json}
Expand All @@ -235,7 +228,7 @@ type: skill
error_type: ${NETWORK_SUBGRAPH_ERROR_TYPE:str:dict}
retries: ${TRADES_SUBGRAPH_RETRIES:int:5}
url: ${TRADES_SUBGRAPH_URL:str:https://api.thegraph.com/subgraphs/name/protofire/omen-xdai}
conditional_tokens_subgraph: &id012
conditional_tokens_subgraph: &id011
args:
headers:
Content-Type: ${CONDITIONAL_TOKENS_SUBGRAPH_CONTENT_TYPE:str:application/json}
Expand All @@ -247,7 +240,7 @@ type: skill
error_type: ${NETWORK_SUBGRAPH_ERROR_TYPE:str:dict}
retries: ${CONDITIONAL_TOKENS_SUBGRAPH_RETRIES:int:5}
url: ${CONDITIONAL_TOKENS_SUBGRAPH_URL:str:https://api.thegraph.com/subgraphs/name/gnosis/conditional-tokens-gc}
realitio_subgraph: &id013
realitio_subgraph: &id012
args:
headers:
Content-Type: ${REALITIO_SUBGRAPH_CONTENT_TYPE:str:application/json}
Expand Down Expand Up @@ -365,15 +358,14 @@ type: skill
rpc_sleep_time: ${RPC_SLEEP_TIME:int:10}
mech_interaction_sleep_time: ${MECH_INTERACTION_SLEEP_TIME:int:10}
benchmark_tool: *id004
acc_info_fields: *id005
network_subgraph: *id006
omen_subgraph: *id007
randomness_api: *id008
mech_response: *id009
agent_tools: *id010
trades_subgraph: *id011
conditional_tokens_subgraph: *id012
realitio_subgraph: *id013
network_subgraph: *id005
omen_subgraph: *id006
randomness_api: *id007
mech_response: *id008
agent_tools: *id009
trades_subgraph: *id010
conditional_tokens_subgraph: *id011
realitio_subgraph: *id012
2:
models:
params:
Expand Down Expand Up @@ -480,15 +472,14 @@ type: skill
rpc_sleep_time: ${RPC_SLEEP_TIME:int:10}
mech_interaction_sleep_time: ${MECH_INTERACTION_SLEEP_TIME:int:10}
benchmark_tool: *id004
acc_info_fields: *id005
network_subgraph: *id006
omen_subgraph: *id007
randomness_api: *id008
mech_response: *id009
agent_tools: *id010
trades_subgraph: *id011
conditional_tokens_subgraph: *id012
realitio_subgraph: *id013
network_subgraph: *id005
omen_subgraph: *id006
randomness_api: *id007
mech_response: *id008
agent_tools: *id009
trades_subgraph: *id010
conditional_tokens_subgraph: *id011
realitio_subgraph: *id012
3:
models:
params:
Expand Down Expand Up @@ -595,15 +586,14 @@ type: skill
rpc_sleep_time: ${RPC_SLEEP_TIME:int:10}
mech_interaction_sleep_time: ${MECH_INTERACTION_SLEEP_TIME:int:10}
benchmark_tool: *id004
acc_info_fields: *id005
network_subgraph: *id006
omen_subgraph: *id007
randomness_api: *id008
mech_response: *id009
agent_tools: *id010
trades_subgraph: *id011
conditional_tokens_subgraph: *id012
realitio_subgraph: *id013
network_subgraph: *id005
omen_subgraph: *id006
randomness_api: *id007
mech_response: *id008
agent_tools: *id009
trades_subgraph: *id010
conditional_tokens_subgraph: *id011
realitio_subgraph: *id012
---
public_id: valory/ledger:0.19.0
type: connection
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/services/trader_pearl/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license: Apache-2.0
fingerprint:
README.md: bafybeibg7bdqpioh4lmvknw3ygnllfku32oca4eq5pqtvdrdsgw6buko7e
fingerprint_ignore_patterns: []
agent: valory/trader:0.1.0:bafybeiaxm4ts4odvhmbltyaa7rngm6jio7b4fdwvwszahw2ndfjdpd547a
agent: valory/trader:0.1.0:bafybeicpf66igauitqbhnt24scqrmlxfu6ervkfyq2tucejxxz33f2rbtu
number_of_agents: 1
deployment:
agent:
Expand Down
44 changes: 15 additions & 29 deletions packages/valory/skills/decision_maker_abci/behaviours/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
from packages.valory.skills.abstract_round_abci.behaviour_utils import TimeoutException
from packages.valory.skills.decision_maker_abci.io_.loader import ComponentPackageLoader
from packages.valory.skills.decision_maker_abci.models import (
AccuracyInfoFields,
BenchmarkingMockData,
BenchmarkingMode,
CONFIDENCE_FIELD,
DecisionMakerParams,
Expand Down Expand Up @@ -173,19 +171,6 @@ def benchmarking_mode(self) -> BenchmarkingMode:
"""Return the benchmarking mode configurations."""
return cast(BenchmarkingMode, self.context.benchmarking_mode)

@property
def mock_data(self) -> BenchmarkingMockData:
"""Return the mock data for the benchmarking mode."""
mock_data = self.shared_state.mock_data
if mock_data is None:
raise ValueError("Attempted to access the mock data while being empty!")
return mock_data

@property
def acc_info_fields(self) -> AccuracyInfoFields:
"""Return the accuracy information fieldnames."""
return cast(AccuracyInfoFields, self.context.acc_info_fields)

@property
def shared_state(self) -> SharedState:
"""Get the shared state."""
Expand Down Expand Up @@ -256,11 +241,7 @@ def policy(self) -> EGreedyPolicy:
@property
def is_first_period(self) -> bool:
"""Return whether it is the first period of the service."""
return (
self.synchronized_data.period_count == 0
and not self.benchmarking_mode.enabled
or self.shared_state.mock_data is None
)
return self.synchronized_data.period_count == 0

@property
def sampled_bet(self) -> Bet:
Expand Down Expand Up @@ -599,7 +580,6 @@ def wait_for_condition_with_sleep(
self,
condition_gen: Callable[[], WaitableConditionType],
timeout: Optional[float] = None,
sleep_time_override: Optional[int] = None,
) -> Generator[None, None, None]:
"""Wait for a condition to happen and sleep in-between checks.
Expand All @@ -609,8 +589,6 @@ def wait_for_condition_with_sleep(
:param condition_gen: a generator of the condition to wait for
:param timeout: the maximum amount of time to wait
:param sleep_time_override: override for the sleep time.
If None is given, the default value is used, which is the RPC timeout set in the configuration.
:yield: None
"""

Expand All @@ -620,15 +598,16 @@ def wait_for_condition_with_sleep(
else datetime.max
)

sleep_time = sleep_time_override or self.params.rpc_sleep_time
while True:
condition_satisfied = yield from condition_gen()
if condition_satisfied:
break
if timeout is not None and datetime.now() > deadline:
raise TimeoutException()
self.context.logger.info(f"Retrying in {sleep_time} seconds.")
yield from self.sleep(sleep_time)
self.context.logger.info(
f"Retrying in {self.params.rpc_sleep_time} seconds."
)
yield from self.sleep(self.params.rpc_sleep_time)

def _write_benchmark_results(
self,
Expand All @@ -639,6 +618,13 @@ def _write_benchmark_results(
liquidity_info: LiquidityInfo = INIT_LIQUIDITY_INFO,
) -> None:
"""Write the results to the benchmarking file."""
mock_data = self.shared_state.mock_data
if mock_data is None:
self.context.logger.error(
"The mock data are empty! Cannot write the benchmark result."
)
return

add_headers = False
results_path = self.params.store_path / self.benchmarking_mode.results_filename
if not os.path.isfile(results_path):
Expand All @@ -663,11 +649,11 @@ def _write_benchmark_results(
results_file.write(row)

results = (
self.mock_data.id,
mock_data.id,
# reintroduce duplicate quotes and quote the question
# as it may contain commas which are also used as separators
QUOTE + self.mock_data.question.replace(QUOTE, TWO_QUOTES) + QUOTE,
self.mock_data.answer,
QUOTE + mock_data.question.replace(QUOTE, TWO_QUOTES) + QUOTE,
mock_data.answer,
p_yes,
p_no,
confidence,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def _prepare_safe_tx(self) -> Generator[None, None, Optional[str]]:
outcome = self.sampled_bet.get_outcome(self.outcome_index)
investment = self._collateral_amount_info(self.investment_amount)
self.context.logger.info(
f"Preparing a multisig transaction to place a bet for {outcome!r}, with confidence "
f"Preparing a mutlisig transaction to place a bet for {outcome!r}, with confidence "
f"{self.synchronized_data.confidence!r}, for the amount of {investment}, which is equal to the amount of "
f"{self.buy_amount!r} WEI of the conditional token corresponding to {outcome!r}."
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,30 @@ def synced_time(self) -> float:
return synced_time.timestamp()

def _blacklist(self) -> None:
"""Blacklist the sampled bet."""
"""Update the policy and blacklist the sampled bet."""
# calculate the penalty
if self.synchronized_data.is_mech_price_set:
# impose a penalty equivalent to the mech's price on the tool responsible for blacklisting the market
penalty_wei = self.synchronized_data.mech_price
elif self.benchmarking_mode.enabled:
# penalize using the simulated mech's cost
penalty_wei = self.benchmarking_mode.mech_cost
else:
# if the price has not been set or a nevermined subscription is used, penalize using a small amount,
# approximating the cost of a transaction
penalty_wei = -TX_COST_APPROX

# update the policy to penalize the most recently utilized mech tool
tool_idx = self.synchronized_data.mech_tool_idx
penalty = -self.wei_to_native(penalty_wei)
penalty *= self.params.tool_punishment_multiplier
self.policy.add_reward(tool_idx, penalty)

if self.benchmarking_mode.enabled:
# skip blacklisting the market as we should be based solely on the input data of the simulation
return

# blacklist the sampled bet
sampled_bet_index = self.synchronized_data.sampled_bet_index
sampled_bet = self.bets[sampled_bet_index]
sampled_bet.status = BetStatus.BLACKLISTED
Expand All @@ -67,9 +90,7 @@ def async_act(self) -> Generator:

with self.context.benchmark_tool.measure(self.behaviour_id).local():
self.read_bets()
# skip blacklisting when benchmarking as we should be based solely on the input data of the simulation
if not self.benchmarking_mode.enabled:
self._blacklist()
self._blacklist()
self.store_bets()
bets_hash = (
None if self.benchmarking_mode.enabled else self.hash_stored_bets()
Expand Down
Loading

0 comments on commit b0d3524

Please sign in to comment.