Skip to content

Latest commit

 

History

History
79 lines (56 loc) · 4.47 KB

play-with-index.md

File metadata and controls

79 lines (56 loc) · 4.47 KB

Play With inDEX

Suppose we are playing on poc5, after deployed executor and keystore contract, add the owner account mnemonic and cloud storage base url, access token (only support Google firebase so far) to the .env file

URI="<your mnemonic>"
STORAGE_URL="<your storage base url>"
STORAGE_KEY="<your storage access token>"

then update the value of executor_contract_id and key_store_contract_id in scripts/src/config.poc5.json with the proper contract id that you deployed just now.

Now we are ready to start contract configuration

[1] Whitelist executor contract id on keystore contract

Instead of change worker accounts everytime we deployed executor engine, we split the worker accounts generation to keystore contract. Only whitelisted executor contract id can get private keys of worker accounts from keystore contract, cd scripts and execute

node src/console.js --config src/config.poc5.json keystore set-executor

[2] Config executor contract

We need to config executor contract after deployed, stuff contains:

  1. import worker key from KeyStore contract (call executor.config);
  2. setup worker account in remote storage (call executor.setup_worker_on_storage);
  3. [Optional] resume executor (call executor.resume_executor);

Now, issue command

node src/console.js --config src/config.poc5.json executor setup --resume

with --resume will unpause the executor (executor is paused by default after deployed). You will get the output like below:

✅ Config executor
✅ Config storage
✅ Resume executor
🎉 Finished executor configuration!

Run scheduler

The scheduler is responsible for scheduling the execution of inDEX engine. It will call executor.run periodically to 1) fetch tasks that distributed to a specific worker from handler on source chain and 2) run tasks that are successfully claimed by the worker. Also it will update the access token generated by gcloud cli command periodically.

Issue command

node src/console.js --config src/config.poc5.json scheduler run --fetch-interval 30000 --execute-interval 10000 --token-update-interval 600000

** Don't forget fund the worker account on specific chain to pay gas fee **

Others

  • You may need to deposit your task with handler contract

Suppose you got solution data like below:

SOLUTION_DATA="[{\"exe_type\":\"swap\",\"exe\":\"moonbeam_stellaswap\",\"source_chain\":\"Moonbeam\",\"dest_chain\":\"Moonbeam\",\"spend_asset\":\"0xAcc15dC74880C9944775448304B263D191c6077F\",\"receive_asset\":\"0xFfFFfFff1FcaCBd218EDc0EbA20Fc2308C778080\"},{\"exe_type\":\"swap\",\"exe\":\"moonbeam_stellaswap\",\"source_chain\":\"Moonbeam\",\"dest_chain\":\"Moonbeam\",\"spend_asset\":\"0xFfFFfFff1FcaCBd218EDc0EbA20Fc2308C778080\",\"receive_asset\":\"0xFFFfFfFf63d24eCc8eB8a7b5D0803e900F7b6cED\"},{\"exe_type\":\"bridge\",\"exe\":\"moonbeam_bridge_to_phala\",\"source_chain\":\"Moonbeam\",\"dest_chain\":\"Phala\",\"spend_asset\":\"0xFFFfFfFf63d24eCc8eB8a7b5D0803e900F7b6cED\",\"receive_asset\":\"0x0000\"},{\"exe_type\":\"bridge\",\"exe\":\"phala_bridge_to_astar\",\"source_chain\":\"Phala\",\"dest_chain\":\"Astar\",\"spend_asset\":\"0x0000\",\"receive_asset\":\"0x010100cd1f\"},{\"exe_type\":\"bridge\",\"exe\":\"astar_bridge_to_astarevm\",\"source_chain\":\"Astar\",\"dest_chain\":\"AstarEvm\",\"spend_asset\":\"0x010100cd1f\",\"receive_asset\":\"0xFFFFFFFF00000000000000010000000000000006\"},{\"exe_type\":\"swap\",\"exe\":\"astar_evm_arthswap\",\"source_chain\":\"AstarEvm\",\"dest_chain\":\"AstarEvm\",\"spend_asset\":\"0xFFFFFFFF00000000000000010000000000000006\",\"receive_asset\":\"0xaeaaf0e2c81af264101b9129c00f4440ccf0f720\"},{\"exe_type\":\"swap\",\"exe\":\"astar_evm_arthswap\",\"source_chain\":\"AstarEvm\",\"dest_chain\":\"AstarEvm\",\"spend_asset\":\"0xaeaaf0e2c81af264101b9129c00f4440ccf0f720\",\"receive_asset\":\"0xFFFFFFFF00000000000000010000000000000003\"}]"

then deposit task in Handler contract we deployed on Moonbeam for test:

node src/console.js --config src/config.poc5.json handler deposit --chain Moonbeam \
--asset 0xAcc15dC74880C9944775448304B263D191c6077F \
--amount 2000000000000000000 \
--recipient 0x7804e66ec9eea3d8daf6273ffbe0a8af25a8879cf43f14d0ebbb30941f578242 \
--worker "0xbfd542cf8d41e84b70a96c9b379913be6917acfb" \
--id "0x0000000000000000000000000000000000000000000000000000000000000005" \
--data  $SOLUTION_DATA \
--key <sender private key>

Note --id specifies the task id, you can generate it on your way