Skip to content

Commit

Permalink
Merge pull request #2 from valory-xyz/feat/complete
Browse files Browse the repository at this point in the history
Feat/complete
  • Loading branch information
dvilelaf authored Oct 15, 2024
2 parents c8c6b47 + b616596 commit 527f6a2
Show file tree
Hide file tree
Showing 20 changed files with 661 additions and 159 deletions.
3 changes: 2 additions & 1 deletion .spelling
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ keys.json
xDAI
Coingecko
mainnet
testnet
testnet
4-agent
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,28 @@ A service to learn about [Olas](https://olas.network/) agents and [Open Autonomy
2. Prepare a `ethereum_private_key.txt` file containing one of the private keys from `keys.json`. Ensure that there is no newline at the end.
3. Deploy a [Safe on Gnosis](https://app.safe.global/welcome) (it's free) and set your agent addresses as signers. Set the signature threshold to 3 out of 4.
3. Deploy two [Safes on Gnosis](https://app.safe.global/welcome) (it's free) and set your agent addresses as signers. Set the signature threshold to 1 out of 4 for one of them and and to 3 out of 4 for the other. This way we can use the single-signer one for testing without running all the agents, and leave the other safe for running the whole service.
4. Create a [Tenderly](https://tenderly.co/) account and from your dashboard create a fork of Gnosis chain (virtual testnet).
5. From Tenderly, fund your agents and Safe with a small amount of xDAI, i.e. $0.02 each.
5. From Tenderly, fund your agents and Safe with some xDAI and OLAS (`0xcE11e14225575945b8E6Dc0D4F2dD4C570f79d9f`).
6. Make a copy of the env file:
```
cp sample.env .env
```
7. Fill in the required environment variables in .env. These variables are: `ALL_PARTICIPANTS`, `GNOSIS_LEDGER_RPC`, `COINGECKO_API_KEY` and `SAFE_CONTRACT_ADDRESS`. You will need to get a [Coingecko](https://www.coingecko.com/). Set `GNOSIS_LEDGER_RPC` to your Tenderly fork Admin RPC.
7. Fill in the required environment variables in .env. These variables are:
- `ALL_PARTICIPANTS`: a list of your agent addresses. This will vary depending on whether you are running a single agent (`run_agent.sh` script) or the whole 4-agent service (`run_service.sh`)
- `GNOSIS_LEDGER_RPC`: set it to your Tenderly fork Admin RPC.
- `COINGECKO_API_KEY`: you will need to get a free [Coingecko](https://www.coingecko.com/) API key.
- `TRANSFER_TARGET_ADDRESS`: any random address to send funds to, can be any of the agents for example.
- `SAFE_CONTRACT_ADDRESS_SINGLE`: the 1 out of 4 agents Safe address.
- `SAFE_CONTRACT_ADDRESS`: the 3 out of 4 Safe address.
### Run a single agent
### Run a single agent locally
1. Verify that `ALL_PARTICIPANTS` in `.env` contains only 1 address.
Expand All @@ -74,16 +80,16 @@ A service to learn about [Olas](https://olas.network/) agents and [Open Autonomy
bash run_agent.sh
```
### Run the service (4 agents)
### Run the service (4 agents) via Docker Compose deployment
1. Check that Docker is running:
1. Verify that `ALL_PARTICIPANTS` in `.env` contains 4 address.
2. Check that Docker is running:
```
docker
```
2. Verify that `ALL_PARTICIPANTS` in `.env` contains 4 addresses.
3. Run the service:
```
Expand Down
10 changes: 5 additions & 5 deletions packages/packages.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"dev": {
"contract/valory/erc20/0.1.0": "bafybeiel24epwfr5nsk5xt2dfdimrzhrqchjxdeeh6wpm6nz35w6po6osa",
"skill/valory/learning_abci/0.1.0": "bafybeiddwdmznotlmqpdpz4jfjaxrls466mwwvodbvthijuo3dvkbvjvmq",
"skill/valory/learning_chained_abci/0.1.0": "bafybeifgnpc5ffvhgjehufna25t2zss4yjmzvjza6l667burz2ukmrr5uq",
"agent/valory/learning_agent/0.1.0": "bafybeidek5ctvxoxxoyf3uvgyoe6es5strfpbb2h6r2eqktumyoihgmj4m",
"service/valory/learning_service/0.1.0": "bafybeia54zy6nolxzrgybes7ljxt2chwi7vkcrweg6hfz2le5gpehvdb6y"
"contract/valory/erc20/0.1.0": "bafybeibk2y6ldylquuikk3cmtk64e2wnjbtuxy5doorzsp4ysx6uwqbdxm",
"skill/valory/learning_abci/0.1.0": "bafybeih2g2tlqwh4dmvlqiielp3e4ogys7bqxdebkdz6wmztfetdtmsu3i",
"skill/valory/learning_chained_abci/0.1.0": "bafybeichwyiomzdi6ukountryerhae3j53k6at4nk7id2mmkrn26wano6q",
"agent/valory/learning_agent/0.1.0": "bafybeiac6su37yg5w2zsxlxytvtiwxzjywf4i2x3x6eledlrjbk724aptq",
"service/valory/learning_service/0.1.0": "bafybeihcjtjfpuaa7aga4nx7xqlyfi66yojeingnt5nepp6apys5jza2am"
},
"third_party": {
"protocol/open_aea/signing/1.0.0": "bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi",
Expand Down
30 changes: 22 additions & 8 deletions packages/valory/agents/learning_agent/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ contracts:
- valory/gnosis_safe_proxy_factory:0.1.0:bafybeihi4cvrnf5ne7t5cxcwix3dbtfjucfjux6zn4wouebjx3ldmrmnpm
- valory/multisend:0.1.0:bafybeig5byt5urg2d2bsecufxe5ql7f4mezg3mekfleeh32nmuusx66p4y
- valory/service_registry:0.1.0:bafybeieqgcuxmz4uxvlyb62mfsf33qy4xwa5lrij4vvcmrtcsfkng43oyq
- valory/erc20:0.1.0:bafybeiel24epwfr5nsk5xt2dfdimrzhrqchjxdeeh6wpm6nz35w6po6osa
- valory/erc20:0.1.0:bafybeibk2y6ldylquuikk3cmtk64e2wnjbtuxy5doorzsp4ysx6uwqbdxm
protocols:
- open_aea/signing:1.0.0:bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi
- valory/abci:0.1.0:bafybeiaqmp7kocbfdboksayeqhkbrynvlfzsx4uy4x6nohywnmaig4an7u
Expand All @@ -32,8 +32,8 @@ protocols:
skills:
- valory/abstract_abci:0.1.0:bafybeihu2bcgjk2tqjiq2zhk3uogtfszqn4osvdt7ho3fubdpdj4jgdfjm
- valory/abstract_round_abci:0.1.0:bafybeibovsktd3uxur45nrcomq5shcn46cgxd5idmhxbmjhg32c5abyqim
- valory/learning_abci:0.1.0:bafybeiddwdmznotlmqpdpz4jfjaxrls466mwwvodbvthijuo3dvkbvjvmq
- valory/learning_chained_abci:0.1.0:bafybeifgnpc5ffvhgjehufna25t2zss4yjmzvjza6l667burz2ukmrr5uq
- valory/learning_abci:0.1.0:bafybeih2g2tlqwh4dmvlqiielp3e4ogys7bqxdebkdz6wmztfetdtmsu3i
- valory/learning_chained_abci:0.1.0:bafybeichwyiomzdi6ukountryerhae3j53k6at4nk7id2mmkrn26wano6q
- valory/registration_abci:0.1.0:bafybeicnth5q4httefsusywx3zrrq4al47owvge72dqf2fziruicq6hqta
- valory/reset_pause_abci:0.1.0:bafybeievjciqdvxhqxfjd4whqs27h6qbxqzrae7wwj7fpvxlvmtw3x35im
- valory/termination_abci:0.1.0:bafybeid54buqxipiuduw7b6nnliiwsxajnltseuroad53wukfonpxca2om
Expand Down Expand Up @@ -99,7 +99,7 @@ public_id: valory/p2p_libp2p_client:0.1.0
type: connection
config:
nodes:
- uri: ${str:acn.staging.autonolas.tech:9005}
- uri: ${str:acn.autonolas.tech:9005}
public_key: ${str:02d3a830c9d6ea1ae91936951430dee11f4662f33118b02190693be835359a9d77}
cert_requests:
- identifier: acn
Expand Down Expand Up @@ -147,7 +147,7 @@ models:
keeper_timeout: 30.0
max_attempts: 10
max_healthcheck: 120
multisend_address: ${str:0x0000000000000000000000000000000000000000}
multisend_address: ${str:0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761}
termination_sleep: ${int:900}
init_fallback_gas: 0
keeper_allowed_retries: 3
Expand All @@ -162,8 +162,8 @@ models:
service_id: learning
service_registry_address: ${str:null}
setup:
all_participants: ${list:["0x615d3278680337e2D39C3bc5042D959C7938B917"]}
safe_contract_address: ${str:0x5C5b146905c11Ee1fE7260c0338b52DCA9582a13}
all_participants: ${list:[]}
safe_contract_address: ${str:0x0000000000000000000000000000000000000000}
consensus_threshold: ${int:null}
share_tm_config_on_startup: ${bool:false}
sleep_time: 1
Expand All @@ -188,5 +188,19 @@ models:
coingecko_api_key: ${str:null}
default_chain_id: ${str:gnosis}
termination_from_block: ${int:34088325}
transfer_target_address: ${str:0x615d3278680337e2D39C3bc5042D959C7938B917}
transfer_target_address: ${str:0x0000000000000000000000000000000000000000}
olas_token_address: ${str:0xcE11e14225575945b8E6Dc0D4F2dD4C570f79d9f}
coingecko_specs:
args:
api_id: coingecko
headers:
Accept: application/json
method: GET
parameters:
ids: autonolas
vs_currencies: usd
x_cg_demo_api_key: ${str:null}
response_key: autonolas
response_type: dict
retries: 5
url: https://api.coingecko.com/api/v3/simple/price
14 changes: 14 additions & 0 deletions packages/valory/contracts/erc20/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,17 @@ def build_approval_tx(
checksumed_spender = ledger_api.api.to_checksum_address(spender)
data = contract_instance.encodeABI("approve", args=(checksumed_spender, amount))
return {"data": bytes.fromhex(data[2:])}

@classmethod
def build_transfer_tx(
cls,
ledger_api: LedgerApi,
contract_address: str,
recipient: str,
amount: int,
) -> Dict[str, bytes]:
"""Build an ERC20 transfer."""
contract_instance = cls.get_instance(ledger_api, contract_address)
checksumed_recipient = ledger_api.api.to_checksum_address(recipient)
data = contract_instance.encodeABI("transfer", args=(checksumed_recipient, amount))
return {"data": bytes.fromhex(data[2:])}
2 changes: 1 addition & 1 deletion packages/valory/contracts/erc20/contract.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fingerprint:
README.md: bafybeifmfma6rglvpa22odtozyosnp5mwljum64utxip2wgmezuhnjjjyi
__init__.py: bafybeif5vpc3dfrlxlch7brbhmdwksabyzddpfqgm56vdbbkek3t3br6ke
build/ERC20.json: bafybeiemn5b5nszuss7xj6lmvmjuendltp6wz7ubihdvd7c6wqw4bohbpa
contract.py: bafybeien5pkaqqlwhp76r2jepzh4c2ww7nbyuyhwxqseeeojxpcmulxixm
contract.py: bafybeidewckxjj6vaz7sphkpnjgmsyhi7v7hijaz44yu7vbsnv3znqj3wm
fingerprint_ignore_patterns: []
contracts: []
class_name: ERC20
Expand Down
68 changes: 62 additions & 6 deletions packages/valory/services/learning_service/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: bafybeid42pdrf6qrohedylj4ijrss236ai6geqgf3he44huowiuf7pl464
fingerprint_ignore_patterns: []
agent: valory/learning_agent:0.1.0:bafybeidek5ctvxoxxoyf3uvgyoe6es5strfpbb2h6r2eqktumyoihgmj4m
agent: valory/learning_agent:0.1.0:bafybeiac6su37yg5w2zsxlxytvtiwxzjywf4i2x3x6eledlrjbk724aptq
number_of_agents: 4
deployment:
agent:
Expand Down Expand Up @@ -92,8 +92,22 @@ extra:
termination_from_block: ${TERMINATION_FROM_BLOCK:int:34088325}
coingecko_price_template: ${COINGECKO_PRICE_TEMPLATE:str:https://api.coingecko.com/api/v3/simple/price?ids=autonolas&vs_currencies=usd&x_cg_demo_api_key={api_key}}
coingecko_api_key: ${COINGECKO_API_KEY:str:null}
transfer_target_address: ${TRANSFER_TARGET_ADDRESS:str:0x615d3278680337e2D39C3bc5042D959C7938B917}
transfer_target_address: ${TRANSFER_TARGET_ADDRESS:str:0x0000000000000000000000000000000000000000}
olas_token_address: ${OLAS_TOKEN_ADDRESS:str:0xcE11e14225575945b8E6Dc0D4F2dD4C570f79d9f}
coingecko_specs:
args:
api_id: coingecko
headers:
Accept: application/json
method: GET
parameters:
ids: autonolas
vs_currencies: usd
x_cg_demo_api_key: ${COINGECKO_API_KEY:str:null}
response_key: autonolas
response_type: dict
retries: 5
url: https://api.coingecko.com/api/v3/simple/price
1:
models:
benchmark_tool:
Expand Down Expand Up @@ -139,8 +153,22 @@ extra:
termination_from_block: ${TERMINATION_FROM_BLOCK:int:34088325}
coingecko_price_template: ${COINGECKO_PRICE_TEMPLATE:str:https://api.coingecko.com/api/v3/simple/price?ids=autonolas&vs_currencies=usd&x_cg_demo_api_key={api_key}}
coingecko_api_key: ${COINGECKO_API_KEY:str:null}
transfer_target_address: ${TRANSFER_TARGET_ADDRESS:str:0x615d3278680337e2D39C3bc5042D959C7938B917}
transfer_target_address: ${TRANSFER_TARGET_ADDRESS:str:0x0000000000000000000000000000000000000000}
olas_token_address: ${OLAS_TOKEN_ADDRESS:str:0xcE11e14225575945b8E6Dc0D4F2dD4C570f79d9f}
coingecko_specs:
args:
api_id: coingecko
headers:
Accept: application/json
method: GET
parameters:
ids: autonolas
vs_currencies: usd
x_cg_demo_api_key: ${COINGECKO_API_KEY:str:null}
response_key: autonolas
response_type: dict
retries: 5
url: https://api.coingecko.com/api/v3/simple/price
2:
models:
benchmark_tool:
Expand Down Expand Up @@ -186,8 +214,22 @@ extra:
termination_from_block: ${TERMINATION_FROM_BLOCK:int:34088325}
coingecko_price_template: ${COINGECKO_PRICE_TEMPLATE:str:https://api.coingecko.com/api/v3/simple/price?ids=autonolas&vs_currencies=usd&x_cg_demo_api_key={api_key}}
coingecko_api_key: ${COINGECKO_API_KEY:str:null}
transfer_target_address: ${TRANSFER_TARGET_ADDRESS:str:0x615d3278680337e2D39C3bc5042D959C7938B917}
transfer_target_address: ${TRANSFER_TARGET_ADDRESS:str:0x0000000000000000000000000000000000000000}
olas_token_address: ${OLAS_TOKEN_ADDRESS:str:0xcE11e14225575945b8E6Dc0D4F2dD4C570f79d9f}
coingecko_specs:
args:
api_id: coingecko
headers:
Accept: application/json
method: GET
parameters:
ids: autonolas
vs_currencies: usd
x_cg_demo_api_key: ${COINGECKO_API_KEY:str:null}
response_key: autonolas
response_type: dict
retries: 5
url: https://api.coingecko.com/api/v3/simple/price
3:
models:
benchmark_tool:
Expand Down Expand Up @@ -233,8 +275,22 @@ extra:
termination_from_block: ${TERMINATION_FROM_BLOCK:int:34088325}
coingecko_price_template: ${COINGECKO_PRICE_TEMPLATE:str:https://api.coingecko.com/api/v3/simple/price?ids=autonolas&vs_currencies=usd&x_cg_demo_api_key={api_key}}
coingecko_api_key: ${COINGECKO_API_KEY:str:null}
transfer_target_address: ${TRANSFER_TARGET_ADDRESS:str:0x615d3278680337e2D39C3bc5042D959C7938B917}
transfer_target_address: ${TRANSFER_TARGET_ADDRESS:str:0x0000000000000000000000000000000000000000}
olas_token_address: ${OLAS_TOKEN_ADDRESS:str:0xcE11e14225575945b8E6Dc0D4F2dD4C570f79d9f}
coingecko_specs:
args:
api_id: coingecko
headers:
Accept: application/json
method: GET
parameters:
ids: autonolas
vs_currencies: usd
x_cg_demo_api_key: ${COINGECKO_API_KEY:str:null}
response_key: autonolas
response_type: dict
retries: 5
url: https://api.coingecko.com/api/v3/simple/price
---
public_id: valory/ledger:0.19.0
type: connection
Expand All @@ -255,7 +311,7 @@ public_id: valory/p2p_libp2p_client:0.1.0
type: connection
config:
nodes:
- uri: ${ACN_URI:str:acn.staging.autonolas.tech:9005}
- uri: ${ACN_URI:str:acn.autonolas.tech:9005}
public_key: ${ACN_NODE_PUBLIC_KEY:str:02d3a830c9d6ea1ae91936951430dee11f4662f33118b02190693be835359a9d77}
cert_requests:
- identifier: acn
Expand Down
Loading

0 comments on commit 527f6a2

Please sign in to comment.