Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Pass arguments to off-chain worker #3912

Closed
xlc opened this issue Oct 25, 2019 · 6 comments
Closed

Pass arguments to off-chain worker #3912

xlc opened this issue Oct 25, 2019 · 6 comments
Labels
J0-enhancement An additional feature request.

Comments

@xlc
Copy link
Contributor

xlc commented Oct 25, 2019

How to pass arguments to off-chain worker? AFAIK it is possible to configure session key for offchain worker to consume. But can this session key be arbitrary string?

For example, I would like to pass API key to off-chain worker so it can fetch data from exchanges. The offchain code can check if it has API key configured to do actual work.

In the end, I would like to build an oracle module that allow people to stake to become an operator. Then they can configure a session key and one or more external services API keys to start submit data using offchain worker. This makes a permisionless decentralised oracle network possible.

@gui1117
Copy link
Contributor

gui1117 commented Oct 25, 2019

it seems arguments to off-chain worker can benefit from the architecture of the chain spec. with availability to changes keys at specific block numbers and extend it.

@tomaka tomaka added the J0-enhancement An additional feature request. label Oct 29, 2019
@gui1117
Copy link
Contributor

gui1117 commented Oct 30, 2019

hmm did I actually understood correctly ?

pass argument to off-chain worker from where ? from the runtime ? or from the cli ?

if it is from the runtime this can be done indeed

@gui1117
Copy link
Contributor

gui1117 commented Oct 30, 2019

In the end, I would like to build an oracle module that allow people to stake to become an operator. Then they can configure a session key and one or more external services API keys to start submit data using offchain worker. This makes a permisionless decentralised oracle network possible.

I don't understand how this make use of arguments ? this key is just in the trie ?

@tomusdrw
Copy link
Contributor

For example, I would like to pass API key to off-chain worker so it can fetch data from exchanges. The offchain code can check if it has API key configured to do actual work.

This should be just inserted to the local offchain worker database under some known key. You can set it up during service or CLI initialisation.

@xlc
Copy link
Contributor Author

xlc commented Oct 30, 2019

Yes like @tomusdrw said. Pass arguments from runtime is easy as offchain worker can just read storage. I would like to pass arguments from CLI or API. Preferably from API so it can be rotated without reboot the node.

The API key can be used to make external service HTTP call. For example: https://github.com/SubstrateOrg/Oracle-Infinity/blob/2f7e05ae936c907600714299fc49de21c3919635/runtime/runtime/src/oracle.rs#L178

@xlc
Copy link
Contributor Author

xlc commented Feb 22, 2020

Fixed by #4694

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
J0-enhancement An additional feature request.
Projects
None yet
Development

No branches or pull requests

4 participants