Skip to content

Commit

Permalink
Merge pull request #131 from valory-xyz/fix/message-propagation
Browse files Browse the repository at this point in the history
Fix contracts' message propagation
  • Loading branch information
Adamantios authored Nov 13, 2023
2 parents 71fb0df + f0829e7 commit a4132c7
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 19 deletions.
10 changes: 5 additions & 5 deletions packages/packages.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"dev": {
"skill/valory/market_manager_abci/0.1.0": "bafybeibrjre5yka3sbvb6lsefgc5yutovb6h4ffzrpecplfkjwtl5i36te",
"skill/valory/decision_maker_abci/0.1.0": "bafybeibrziucwlmmov3f3uvkguhnafz2hyrx7u6wbfxybfouqob3fv3o3y",
"skill/valory/trader_abci/0.1.0": "bafybeidnp6bgbkoewy7vil7ese7oioxmn5th3ncg6q6h4hmpmiuqbna5va",
"skill/valory/decision_maker_abci/0.1.0": "bafybeic6xegb3zbo46uv2q3l63itanw7m26r55ifqo4j4iophos46mppcu",
"skill/valory/trader_abci/0.1.0": "bafybeiaew6nufibg53yuzyrumd2wlqfmiyg3brcwetymvtlnehi6fwlskm",
"contract/valory/market_maker/0.1.0": "bafybeif4mm2s3gxtvp227yypkcnna5ftec7vajcftvtbdmqddh7nprah5m",
"agent/valory/trader/0.1.0": "bafybeibr7gzvfrmjikd4gdpzbydpq7nmimfc73x2j6ylugumjksdo2ehvy",
"service/valory/trader/0.1.0": "bafybeihnibsqzi7zh76n5zqyedgbdhllzjkgv42qbrizz45py3vq63zfgq",
"agent/valory/trader/0.1.0": "bafybeigdtxgx2dwsw77j6cmp3ld42cin335q5m4n34uwkwtbnageiefate",
"service/valory/trader/0.1.0": "bafybeibluamqcl2brsm2rirkudtv22gsglohwuruhhlzm6viqjcisc5y5i",
"contract/valory/erc20/0.1.0": "bafybeieqj7dea4tcv6z2yqkgtmhd23vbiycsr5trhwxdvlbwulpl6vhmam",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeignm364fpxacve4m3xb6hzwlizi4przws7noyocqdeqmlmx6xecty",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeiep7dgp7hpamdw6avwku5f5wpqw6zbg4evaux6s4yna6el3jay2x4",
"contract/valory/mech/0.1.0": "bafybeihvc6btuk3nvernzcx4qpezvuhiw2wwnagqj5nkeljvszghv7mq64",
"contract/valory/realitio/0.1.0": "bafybeiamgkwwqhray4fs2hlipwxkq7mosmi7ev7jut4vneetaaycc4ruji",
"contract/valory/realitio_proxy/0.1.0": "bafybeidx37xzjjmapwacedgzhum6grfzhp5vhouz4zu3pvpgdy5pgb2fr4",
Expand Down
6 changes: 3 additions & 3 deletions packages/valory/agents/trader/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ skills:
- valory/reset_pause_abci:0.1.0:bafybeicpxn2khtaesuf4cq6ypwdmdmonlqroj2q2i6cxvpizc2y4cw66pe
- valory/termination_abci:0.1.0:bafybeieqm46zuccaagnko3qlw6p3nvoohdrfgvpmw467r5lyil2dqrzjsy
- valory/transaction_settlement_abci:0.1.0:bafybeia6cdxdlqrcwk2maw25fo7dafzd2p3rs7syropvufophk2pitzbwy
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeignm364fpxacve4m3xb6hzwlizi4przws7noyocqdeqmlmx6xecty
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiep7dgp7hpamdw6avwku5f5wpqw6zbg4evaux6s4yna6el3jay2x4
- valory/market_manager_abci:0.1.0:bafybeibrjre5yka3sbvb6lsefgc5yutovb6h4ffzrpecplfkjwtl5i36te
- valory/decision_maker_abci:0.1.0:bafybeibrziucwlmmov3f3uvkguhnafz2hyrx7u6wbfxybfouqob3fv3o3y
- valory/trader_abci:0.1.0:bafybeidnp6bgbkoewy7vil7ese7oioxmn5th3ncg6q6h4hmpmiuqbna5va
- valory/decision_maker_abci:0.1.0:bafybeic6xegb3zbo46uv2q3l63itanw7m26r55ifqo4j4iophos46mppcu
- valory/trader_abci:0.1.0:bafybeiaew6nufibg53yuzyrumd2wlqfmiyg3brcwetymvtlnehi6fwlskm
default_ledger: ethereum
required_ledgers:
- ethereum
Expand Down
2 changes: 1 addition & 1 deletion 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:bafybeibr7gzvfrmjikd4gdpzbydpq7nmimfc73x2j6ylugumjksdo2ehvy
agent: valory/trader:0.1.0:bafybeigdtxgx2dwsw77j6cmp3ld42cin335q5m4n34uwkwtbnageiefate
number_of_agents: 4
deployment: {}
---
Expand Down
13 changes: 7 additions & 6 deletions packages/valory/skills/decision_maker_abci/behaviours/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,20 +358,21 @@ def default_error(
f"using {contract_callable!r}: {response_msg}"
)

def _propagate_contract_messages(self, response_msg: ContractApiMessage) -> None:
def _propagate_contract_messages(self, response_msg: ContractApiMessage) -> bool:
"""Propagate the contract's message to the logger, if exists.
Contracts can only return one message at a time.
:param response_msg: the response message from the contract method.
:return: None
:return: whether a message has been propagated.
"""
for level in ("info", "warning", "error"):
msg = response_msg.raw_transaction.body.get(level, None)
if msg is not None:
logger = getattr(self.context.logger, level)
logger(msg)
return
return True
return False

def contract_interact(
self,
Expand All @@ -396,11 +397,11 @@ def contract_interact(
self.default_error(contract_id, contract_callable, response_msg)
return False

self._propagate_contract_messages(response_msg)

propagated = self._propagate_contract_messages(response_msg)
data = response_msg.raw_transaction.body.get(data_key, None)
if data is None:
self.default_error(contract_id, contract_callable, response_msg)
if not propagated:
self.default_error(contract_id, contract_callable, response_msg)
return False

setattr(self, placeholder, data)
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/skills/decision_maker_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fingerprint:
README.md: bafybeia367zzdwndvlhw27rvnwodytjo3ms7gbc3q7mhrrjqjgfasnk47i
__init__.py: bafybeih563ujnigeci2ldzh7hakbau6a222vsed7leg3b7lq32vcn3nm4a
behaviours/__init__.py: bafybeih6ddz2ocvm6x6ytvlbcz6oi4snb5ee5xh5h65nq4w2qf7fd7zfky
behaviours/base.py: bafybeidjj7bohyfjze3pu3n3bzain4vu7cmqu6gijcvs4x4ie7yi5g6jkq
behaviours/base.py: bafybeig4apfcv34bdne5tyrdg7balg3lva6c672dt5um5ay45m5pnyjuqm
behaviours/bet_placement.py: bafybeigtz4uimsqjjwq4r5p3a5v6niqdtqezbuf2ghy6o7syhsh4k5gjfa
behaviours/blacklisting.py: bafybeicl6b4hcmqmekta2mcuhkkydnzk7jmic6k44e6ns3u2ibad3awzvu
behaviours/decision_receive.py: bafybeifacce2ke7oltnwnpdjdqfd74eaaw5wxnjfzk6c5tqdsxsmbzjj3m
Expand Down
4 changes: 2 additions & 2 deletions packages/valory/skills/trader_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ skills:
- valory/transaction_settlement_abci:0.1.0:bafybeia6cdxdlqrcwk2maw25fo7dafzd2p3rs7syropvufophk2pitzbwy
- valory/termination_abci:0.1.0:bafybeieqm46zuccaagnko3qlw6p3nvoohdrfgvpmw467r5lyil2dqrzjsy
- valory/market_manager_abci:0.1.0:bafybeibrjre5yka3sbvb6lsefgc5yutovb6h4ffzrpecplfkjwtl5i36te
- valory/decision_maker_abci:0.1.0:bafybeibrziucwlmmov3f3uvkguhnafz2hyrx7u6wbfxybfouqob3fv3o3y
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeignm364fpxacve4m3xb6hzwlizi4przws7noyocqdeqmlmx6xecty
- valory/decision_maker_abci:0.1.0:bafybeic6xegb3zbo46uv2q3l63itanw7m26r55ifqo4j4iophos46mppcu
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiep7dgp7hpamdw6avwku5f5wpqw6zbg4evaux6s4yna6el3jay2x4
behaviours:
main:
args: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contracts: []
protocols: []
skills:
- valory/abstract_round_abci:0.1.0:bafybeid7neqpxxe4ualp23gxgrtpf6r5u3myr2mmc4uvwameyqshfdoydq
- valory/decision_maker_abci:0.1.0:bafybeibrziucwlmmov3f3uvkguhnafz2hyrx7u6wbfxybfouqob3fv3o3y
- valory/decision_maker_abci:0.1.0:bafybeic6xegb3zbo46uv2q3l63itanw7m26r55ifqo4j4iophos46mppcu
behaviours:
main:
args: {}
Expand Down

0 comments on commit a4132c7

Please sign in to comment.