Skip to content

Commit

Permalink
Merge pull request #150 from valory-xyz/fix/serice-type
Browse files Browse the repository at this point in the history
fix: small service fixes
  • Loading branch information
0xArdi authored Mar 31, 2023
2 parents 3b4a1cb + 477c4ff commit dcd32f1
Show file tree
Hide file tree
Showing 35 changed files with 1,232 additions and 67 deletions.
33 changes: 17 additions & 16 deletions packages/packages.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
{
"dev": {
"contract/valory/keep3r_v1_library/0.1.0": "bafybeiguyavczsaebbh5docth3o6e36b24s46jynhvysewnk3hqim3a4qe",
"contract/valory/keep3r_test_job/0.1.0": "bafybeiey4oiqiugcbvvvxyy4pm7qhiidmxl22ilg4wmsvbfag2tjptvnrq",
"contract/valory/keep3r_test_job/0.1.0": "bafybeifdpote2zjamgsqc5ix24p4gppj3knb23uxckobr5za7p6gpjpoqa",
"contract/valory/keep3r_v1/0.1.0": "bafybeidbdfpmzxyw5n47nstnoxhwmtph7nysdiou5snabtpcjsykopwr24",
"skill/valory/keep3r_job/0.1.0": "bafybeiflbm45r3gr2nv7pebwwq2vbapy7okoqj57nynfsq6m3yzghsbjka",
"skill/valory/keep3r_abci/0.1.0": "bafybeihakxp2zvfmvynybkciuf5tsbkdzaym7mbbulyo4itfsl7ou3ovve",
"agent/valory/keep3r_bot/0.1.0": "bafybeiczanoqalggxexil6b7ibikkfkyrmwxsj2okasdwootn53ehndgem",
"skill/valory/keep3r_job/0.1.0": "bafybeiezok7h2j7tjkzxpm4qk35rnszretvrkv3dzpqn3kuvbymlvstoua",
"skill/valory/keep3r_abci/0.1.0": "bafybeifm6xhwi47zkqxdtsoh2ich2xtdioqpx6jj3hgskoljo6q4zxaqzm",
"agent/valory/keep3r_bot/0.1.0": "bafybeiaudehe2roq4yauufe7x5lyy3t3h2db4cxkum4iy7g5bznf5mqn4y",
"contract/valory/keep3r_job/0.1.0": "bafybeiajy32pvqdzbecg2obmlnzdg756srtsmfzn4ujl5ybclx4hfvceli",
"contract/valory/keep3r_for_testnet/0.1.0": "bafybeifytr77v27emxwwoklkytt63h46z4ntedfrvop5tjdq2swxl2tkv4",
"contract/valory/deposit_manager_job/0.1.0": "bafybeihef6awneikf7vulps5vo25xjrbis6fuo5ol3zj67s5eeqr5ki24u",
"contract/valory/phuture_harvesting_job/0.1.0": "bafybeieby42jubdphepg54szpcltoxrirxriohxgobyjsjlop6mbxetlwq",
"contract/valory/keep3r_my_job/0.1.0": "bafybeica2bp4ahe3c4zrgjjo4t6ende7tdxeml63rtpp2d3fcvwif4b3dq",
"service/valory/keep3r_bot/0.1.0": "bafybeifljg667gwr3id3nvzdpynppuhjchc7oknmgz5m34txtxszrqlzwm",
"service/valory/keep3r_bot_goerli/0.1.0": "bafybeicy64ewk2r7pmlfswasyewbjortwtus4qf4khj43cjmeakd7verem",
"contract/valory/yearn_factory_harvest_job/0.1.0": "bafybeihdhbpuhopvf54y6agodpmyki7fgxhvtg2accsp3aqv37ryjqaghu",
"contract/valory/deposit_manager_job/0.1.0": "bafybeiaawvyxk75ljmf5bdlfofijl5a3ji4rc3aywpess56dmnho4vxzvm",
"contract/valory/phuture_harvesting_job/0.1.0": "bafybeieg2v6pztx4jlafdo3cdydrjnhgnxctbraticzs5dh3my3ue5ztue",
"contract/valory/keep3r_my_job/0.1.0": "bafybeicgw4mudefo3opa4udbw67qznfkqoewifg3dc2rwtayef7ctwakbq",
"service/valory/keep3r_bot/0.1.0": "bafybeib63p2dxexph77q22gw4erlzh5fuemmtv5t344tvekc47mcevrk6q",
"service/valory/keep3r_bot_goerli/0.1.0": "bafybeigge7ubbuld4lgs6tg6bhwb2ypzmarjuseh46jxapuo47bdwgc72m",
"contract/valory/yearn_factory_harvest_job/0.1.0": "bafybeiarfp4m4id77tsbpprcmcm5nv6ihwkeenrgrb6kth47uvkqhmh5za",
"protocol/valory/ledger_api/1.0.0": "bafybeieylbg4qb3dmjlm3zufqcwq4qbygsdgj3jzc53eyoqmd25mdz2pkq",
"connection/valory/ledger/0.19.0": "bafybeiez7rieszhh3kmgvz6tvii2ysgx4lbyrhyfujrx3hkmj2gn52b6zu",
"skill/valory/abstract_round_abci/0.1.0": "bafybeibw7khdmdxinnugbjdirh5q4cb4rirf5aqzfj6ai6zbhe7aavr7gy",
"skill/valory/registration_abci/0.1.0": "bafybeigijk6tyixlbb3jhrlgxfzk7wqopegqbdbklflvor27n3ysu42zty",
"skill/valory/reset_pause_abci/0.1.0": "bafybeid4atrdi3mflnkg6hiylnmjbfqa323i3wkjhuj4jispxbchukwwiq",
"skill/valory/transaction_settlement_abci/0.1.0": "bafybeie6mefwzprsqd6n45aleswygs76oekvdlzblq72omjsjtmwdaqwly",
"skill/valory/termination_abci/0.1.0": "bafybeibluiaftasozzpixxhpdcqnxglpmmyfneya7qdi2lc4pnoqzzj7wq"
"connection/valory/ledger/0.19.0": "bafybeih4yf73bwvn3cn44b7on2riqe2lbvixcgw3nze63asvwbmyfqyrc4",
"skill/valory/abstract_round_abci/0.1.0": "bafybeibbxka2c4mvlo2msxi3wtk654fczkfcnbopftyskmd727pjpbty3e",
"skill/valory/registration_abci/0.1.0": "bafybeicjvmdle7qkrid6hpr4nepnvt6pl7oznntfhxy2ftrrciu5vb6sqm",
"skill/valory/reset_pause_abci/0.1.0": "bafybeiay3qgd7jp5xtxqxmbe2net2tm762av42nobosx4atxfjlbe665mi",
"skill/valory/transaction_settlement_abci/0.1.0": "bafybeie5lp57jwtum4uyq4rdkmoue442l6ssdjabi5rbc2di7wtzixw64i",
"skill/valory/termination_abci/0.1.0": "bafybeibpogd2xmkxby7qtst2jyftidnoxqaaaqmvohuphwlyf5tw6ztgwa",
"contract/valory/connext_propagate_job/0.1.0": "bafybeiesmwltwgyexwavl4x4kw37vwsn5igy5bkpwgn5jisombwfgojosq"
},
"third_party": {
"protocol/valory/abci/0.1.0": "bafybeig3dj5jhsowlvg3t73kgobf6xn4nka7rkttakdb2gwsg5bp7rt7q4",
Expand Down
45 changes: 35 additions & 10 deletions packages/valory/agents/keep3r_bot/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ connections:
- valory/abci:0.1.0:bafybeienpqzsym3rg7nnomd6mxgbt4didwd4wfj72oadde27trdmcgsu5y
- valory/http_client:0.23.0:bafybeidykl4elwbcjkqn32wt5h4h7tlpeqovrcq3c5bcplt6nhpznhgczi
- valory/ipfs:0.1.0:bafybeie46fu7mv64q72dwzoxg77zbiv3pzsigzjk3rehjpm47cf3y77mha
- valory/ledger:0.19.0:bafybeiez7rieszhh3kmgvz6tvii2ysgx4lbyrhyfujrx3hkmj2gn52b6zu
- valory/ledger:0.19.0:bafybeih4yf73bwvn3cn44b7on2riqe2lbvixcgw3nze63asvwbmyfqyrc4
- valory/p2p_libp2p_client:0.1.0:bafybeidwcobzb7ut3efegoedad7jfckvt2n6prcmd4g7xnkm6hp6aafrva
contracts:
- valory/gnosis_safe:0.1.0:bafybeicwzsjalj4puagecus525fbdusaljccn4fi62nmr4zp5fhim6oyr4
Expand All @@ -147,12 +147,12 @@ protocols:
- valory/tendermint:0.1.0:bafybeicusvezoqlmyt6iqomcbwaz3xkhk2qf3d56q5zprmj3xdxfy64k54
skills:
- valory/abstract_abci:0.1.0:bafybeigg5ofide2gxwgjvljjgpyy6ombby7ph6pg7erj3h6itduwpn6pqu
- valory/abstract_round_abci:0.1.0:bafybeibw7khdmdxinnugbjdirh5q4cb4rirf5aqzfj6ai6zbhe7aavr7gy
- valory/keep3r_abci:0.1.0:bafybeihakxp2zvfmvynybkciuf5tsbkdzaym7mbbulyo4itfsl7ou3ovve
- valory/keep3r_job:0.1.0:bafybeiflbm45r3gr2nv7pebwwq2vbapy7okoqj57nynfsq6m3yzghsbjka
- valory/registration_abci:0.1.0:bafybeigijk6tyixlbb3jhrlgxfzk7wqopegqbdbklflvor27n3ysu42zty
- valory/reset_pause_abci:0.1.0:bafybeid4atrdi3mflnkg6hiylnmjbfqa323i3wkjhuj4jispxbchukwwiq
- valory/transaction_settlement_abci:0.1.0:bafybeie6mefwzprsqd6n45aleswygs76oekvdlzblq72omjsjtmwdaqwly
- valory/abstract_round_abci:0.1.0:bafybeibbxka2c4mvlo2msxi3wtk654fczkfcnbopftyskmd727pjpbty3e
- valory/keep3r_abci:0.1.0:bafybeifm6xhwi47zkqxdtsoh2ich2xtdioqpx6jj3hgskoljo6q4zxaqzm
- valory/keep3r_job:0.1.0:bafybeiezok7h2j7tjkzxpm4qk35rnszretvrkv3dzpqn3kuvbymlvstoua
- valory/registration_abci:0.1.0:bafybeicjvmdle7qkrid6hpr4nepnvt6pl7oznntfhxy2ftrrciu5vb6sqm
- valory/reset_pause_abci:0.1.0:bafybeiay3qgd7jp5xtxqxmbe2net2tm762av42nobosx4atxfjlbe665mi
- valory/transaction_settlement_abci:0.1.0:bafybeie5lp57jwtum4uyq4rdkmoue442l6ssdjabi5rbc2di7wtzixw64i
default_ledger: ethereum
required_ledgers:
- ethereum
Expand Down Expand Up @@ -194,9 +194,9 @@ public_id: valory/abci:0.1.0
type: connection
config:
target_skill_id: valory/keep3r_abci:0.1.0
host: ${ABCI_HOST:str:localhost}
port: ${ABCI_PORT:int:26658}
use_tendermint: ${ABCI_USE_TENDERMINT:bool:false}
host: ${str:localhost}
port: ${int:26658}
use_tendermint: ${bool:false}
---
public_id: valory/keep3r_abci:0.1.0
type: skill
Expand Down Expand Up @@ -247,6 +247,31 @@ config:
default_gas_price_strategy: ${CONNECTION_LEDGER_CONFIG_LEDGER_APIS_ETHEREUM_DEFAULT_GAS_PRICE_STRATEGY:str:eip1559}
authentication_private_key: ${str:null}
flashbot_relayer_uri: ${str:null}
arbitrum:
address: ${str:http://localhost:8545}
chain_id: ${int:421611}
poa_chain: ${bool:false}
default_gas_price_strategy: ${str:eip1559}
consensys:
address: ${str:http://localhost:8545}
chain_id: ${int:1337}
default_gas_price_strategy: eip1559
poa_chain: false
bnb:
address: ${str:http://localhost:8545}
chain_id: ${int:1337}
poa_chain: ${bool:false}
default_gas_price_strategy: ${str:eip1559}
gnosis:
address: ${str:http://localhost:8545}
chain_id: ${int:1337}
poa_chain: ${bool:false}
default_gas_price_strategy: ${str:eip1559}
zksync:
address: ${str:http://localhost:8545}
chain_id: ${int:1337}
poa_chain: ${bool:false}
default_gas_price_strategy: ${str:eip1559}
---
public_id: valory/p2p_libp2p_client:0.1.0
type: connection
Expand Down
19 changes: 18 additions & 1 deletion packages/valory/connections/ledger/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@ async def wait_for(
func_result = await asyncio.wait_for(running_func, timeout=timeout)
return func_result

def set_extra_kwargs(self, message: Message) -> None:
"""
Set extra kwargs for the provided message.
By default, this method does nothing. Override it in subclasses to set extra kwargs.
:param message: the message that will be decorated with the extra kwargs.
:return: None
"""
return

def dispatch(self, envelope: Envelope) -> Task:
"""
Dispatch the request to the right sender handler.
Expand All @@ -143,7 +154,9 @@ def dispatch(self, envelope: Envelope) -> Task:
raise ValueError("Ledger connection expects non-serialized messages.")
message = envelope.message
ledger_id = self.get_ledger_id(message)
api = self.ledger_api_registry.make(ledger_id, **self.api_config(ledger_id))
chain_id = self.get_chain_id(message)
self.set_extra_kwargs(message)
api = self.ledger_api_registry.make(ledger_id, **self.api_config(chain_id))
dialogue = self.dialogues.update(message)
if dialogue is None:
raise ValueError( # pragma: nocover
Expand Down Expand Up @@ -196,3 +209,7 @@ def ledger_api_registry(self) -> Registry:
@abstractmethod
def get_ledger_id(self, message: Message) -> str:
"""Extract the ledger id from the message."""

@abstractmethod
def get_chain_id(self, message: Message) -> str:
"""Extract the chain id from the message."""
41 changes: 38 additions & 3 deletions packages/valory/connections/ledger/connection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ aea_version: '>=1.0.0, <2.0.0'
fingerprint:
README.md: bafybeihkgodu7o7v6pfazm7u6orlspsfrae3cyz36yc46x67phfmw3l57e
__init__.py: bafybeierqitcqk7oy6m3qp7jgs67lcg55mzt3arltkwimuii2ynfejccwi
base.py: bafybeicpyhus3h2t5urzldnjns2sfwae64uinethqnlunudclbdg4xftnq
base.py: bafybeifxma5dyzyiodirigplulj736ydtexd4kxyjchjiax4nssbfnugei
connection.py: bafybeicydkymhz2feqmihtkiwdfg7pp4pww2elqv4tijuhjcplyvawdk74
contract_dispatcher.py: bafybeigqgqe6zef335t2ygp4celx7445etwjsr42yroc2qmrynwfslgjhq
ledger_dispatcher.py: bafybeibz2uwhgekwov6cw3dalpzokm6kq2bi52c5dkphkwefsz62jrviei
contract_dispatcher.py: bafybeifgtj3ovcu4i7vsanbn5xwntd5eij7i6vgau5tfiycbrftgimkasi
ledger_dispatcher.py: bafybeibx46iad5xvbvo4p7tmwmfwdyscpuwgni262iwrqf5kc46xvs2fiq
tests/__init__.py: bafybeieyhttiwruutk6574yzj7dk2afamgdum5vktyv54gsax7dlkuqtc4
tests/conftest.py: bafybeid7vo7e2m76ey5beeadtbxywxx5ukefd5slwbc362rwmhht6i45ou
tests/test_contract_dispatcher.py: bafybeidpwcnitn5gzgmbtaur3mevme72rsdaax27nu4bs3aqxwixyn4cvy
Expand Down Expand Up @@ -62,6 +62,41 @@ config:
gas_price_strategies: *id001
is_gas_estimation_enabled: true
poa_chain: false
arbitrum:
address: http://127.0.0.1:8545
chain_id: 1337
default_gas_price_strategy: eip1559
gas_price_strategies: *id001
is_gas_estimation_enabled: true
poa_chain: false
zksync:
address: http://127.0.0.1:8545
chain_id: 1337
default_gas_price_strategy: eip1559
gas_price_strategies: *id001
is_gas_estimation_enabled: true
poa_chain: false
bnb:
address: http://127.0.0.1:8545
chain_id: 1337
default_gas_price_strategy: eip1559
gas_price_strategies: *id001
is_gas_estimation_enabled: true
poa_chain: false
gnosis:
address: http://127.0.0.1:8545
chain_id: 1337
default_gas_price_strategy: eip1559
gas_price_strategies: *id001
is_gas_estimation_enabled: true
poa_chain: false
consensys:
address: http://127.0.0.1:8545
chain_id: 1337
default_gas_price_strategy: eip1559
gas_price_strategies: *id001
is_gas_estimation_enabled: true
poa_chain: false
retry_attempts: 240
retry_timeout: 3
excluded_protocols: []
Expand Down
31 changes: 31 additions & 0 deletions packages/valory/connections/ledger/contract_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,3 +415,34 @@ def _validate_and_call_callable(
raise AEAException( # pragma: nocover
f"Unexpected performative: {message.performative}"
)

def get_chain_id(self, message: Message) -> str:
"""
Get the chain id. For ledger messages this is the same as the ledger id, for now.
:param message: the message
:return: the chain id
"""
if not isinstance(message, ContractApiMessage): # pragma: nocover
raise ValueError("argument is not a ContractApiMessage instance.")
message = cast(ContractApiMessage, message)
kwargs = cast(JSONLike, message.kwargs.body)
# if the chain id is specified in the message, use it.
# otherwise, use the ledger id.
chain_id = kwargs.get("chain_id", self.get_ledger_id(message))
return chain_id

def set_extra_kwargs(self, message: Message) -> None:
"""
Set extra kwargs for the contract api message.
:param message: the message
:return: None
"""
if not isinstance(message, ContractApiMessage):
raise ValueError("argument is not a ContractApiMessage instance.")
message = cast(ContractApiMessage, message)
if message.kwargs.body is not None and message.kwargs.body.get(
"set_ledger_api_configs", False
):
message.kwargs.body.update({"ledger_api_configs": self._api_configs.copy()})
9 changes: 9 additions & 0 deletions packages/valory/connections/ledger/ledger_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,3 +453,12 @@ def get_error_message(
),
)
return response

def get_chain_id(self, message: Message) -> str:
"""
Get the chain id. For ledger messages this is the same as the ledger id, for now.
:param message: the message
:return: the chain id
"""
return self.get_ledger_id(message)
Loading

0 comments on commit dcd32f1

Please sign in to comment.