Skip to content

Commit

Permalink
feat: add all missing pieces
Browse files Browse the repository at this point in the history
  • Loading branch information
dvilelaf committed Oct 15, 2024
1 parent 529b142 commit 2d860df
Show file tree
Hide file tree
Showing 15 changed files with 478 additions and 117 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": "bafybeibepvsm2qzi7udwx4lrp2zugdpjpfbtw3xlvm77znhb3ii63w6rdy",
"skill/valory/learning_chained_abci/0.1.0": "bafybeig75qz4mpmoliqrzubyp7oesi63yjx3ucdaseyohm57zhevfzw54q",
"agent/valory/learning_agent/0.1.0": "bafybeidx4wzetzdpma4sxixt7fbxri6q2zj3jfixr6wd7cuo3i2blgjvxu",
"service/valory/learning_service/0.1.0": "bafybeieemuy6f66i4svedvpshtzaxwgltlevwxol7kfghodpufvorrdgsy"
"contract/valory/erc20/0.1.0": "bafybeibk2y6ldylquuikk3cmtk64e2wnjbtuxy5doorzsp4ysx6uwqbdxm",
"skill/valory/learning_abci/0.1.0": "bafybeiccw7sqjxftczyfouy2sh7f2pzheox27pxhwqpptnzetnzeh656vq",
"skill/valory/learning_chained_abci/0.1.0": "bafybeihzhdk4rckazlidfzlz5c57ym3gvrs7zpm5rwbjjg3b2easj3ih7e",
"agent/valory/learning_agent/0.1.0": "bafybeib3f6bwoiltql6bx74tmjj4rd3j4cqy3hsjsuns6dcs5cm73nk4re",
"service/valory/learning_service/0.1.0": "bafybeia4dg6f4s3vgtr3nngvx564phcwhc43ykcbsclpihgn64jgtl257e"
},
"third_party": {
"protocol/open_aea/signing/1.0.0": "bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi",
Expand Down
18 changes: 9 additions & 9 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:bafybeibepvsm2qzi7udwx4lrp2zugdpjpfbtw3xlvm77znhb3ii63w6rdy
- valory/learning_chained_abci:0.1.0:bafybeig75qz4mpmoliqrzubyp7oesi63yjx3ucdaseyohm57zhevfzw54q
- valory/learning_abci:0.1.0:bafybeiccw7sqjxftczyfouy2sh7f2pzheox27pxhwqpptnzetnzeh656vq
- valory/learning_chained_abci:0.1.0:bafybeihzhdk4rckazlidfzlz5c57ym3gvrs7zpm5rwbjjg3b2easj3ih7e
- 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 @@ -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,13 +188,13 @@ 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:
Accepr: application/json
Accept: application/json
method: GET
parameters:
ids: autonolas
Expand All @@ -203,4 +203,4 @@ models:
response_key: autonolas
response_type: dict
retries: 5
url: https://api.coingecko.com/api/v3/simple/price?
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
26 changes: 13 additions & 13 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:bafybeidx4wzetzdpma4sxixt7fbxri6q2zj3jfixr6wd7cuo3i2blgjvxu
agent: valory/learning_agent:0.1.0:bafybeib3f6bwoiltql6bx74tmjj4rd3j4cqy3hsjsuns6dcs5cm73nk4re
number_of_agents: 4
deployment:
agent:
Expand Down Expand Up @@ -92,13 +92,13 @@ 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:
Accepr: application/json
Accept: application/json
method: GET
parameters:
ids: autonolas
Expand All @@ -107,7 +107,7 @@ extra:
response_key: autonolas
response_type: dict
retries: 5
url: https://api.coingecko.com/api/v3/simple/price?
url: https://api.coingecko.com/api/v3/simple/price
1:
models:
benchmark_tool:
Expand Down Expand Up @@ -153,13 +153,13 @@ 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:
Accepr: application/json
Accept: application/json
method: GET
parameters:
ids: autonolas
Expand All @@ -168,7 +168,7 @@ extra:
response_key: autonolas
response_type: dict
retries: 5
url: https://api.coingecko.com/api/v3/simple/price?
url: https://api.coingecko.com/api/v3/simple/price
2:
models:
benchmark_tool:
Expand Down Expand Up @@ -214,13 +214,13 @@ 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:
Accepr: application/json
Accept: application/json
method: GET
parameters:
ids: autonolas
Expand All @@ -229,7 +229,7 @@ extra:
response_key: autonolas
response_type: dict
retries: 5
url: https://api.coingecko.com/api/v3/simple/price?
url: https://api.coingecko.com/api/v3/simple/price
3:
models:
benchmark_tool:
Expand Down Expand Up @@ -275,13 +275,13 @@ 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:
Accepr: application/json
Accept: application/json
method: GET
parameters:
ids: autonolas
Expand All @@ -290,7 +290,7 @@ extra:
response_key: autonolas
response_type: dict
retries: 5
url: https://api.coingecko.com/api/v3/simple/price?
url: https://api.coingecko.com/api/v3/simple/price
---
public_id: valory/ledger:0.19.0
type: connection
Expand Down
Loading

0 comments on commit 2d860df

Please sign in to comment.