Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override jobs #593

Merged
merged 17 commits into from Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
139 changes: 88 additions & 51 deletions README.md
Expand Up @@ -445,57 +445,6 @@ Example:
$ ./razor transfer --value 100 --to 0x91b1E6488307450f4c0442a1c35Bc314A505293e --from 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c
```

### Override Job

Jobs URLs are a placeholder for where to fetch values from. There is a chance that these URLs might either fail, or get razor nodes blacklisted, etc.
`overrideJob` command enables users to override the job URLs and selectors so that razor-nodes can fetch data directly from the override jobs.

razor cli

```
$ ./razor overrideJob --jobId <job_id_to_override> --url <new_url_of_job> --selector <selector_in_json_or_XHTML_selector_format> --power <power> --selectorType <0_for_XHTML_or_1_for_JSON>
```

docker

```
docker run -it \
-v "$(echo $HOME)"/.razor:/root/.razor \
razornetwork/razor-go:latest \
overrideJob --jobId <job_id_to_override> --url <new_url_of_job> --selector <selector_in_json_or_XHTML_selector_format> --power <power> --selectorType <0_for_XHTML_or_1_for_JSON>
```

Example:

```
$ ./razor overrideJob --jobId 2 --url https://api.gemini.com/v1/pubticker/ethusd --selector last --power 2 --selectorType 0
```

### Delete override

The overridden jobs can be deleted using `deleteOverride` command.

razor cli

```
$ ./razor deleteOverride --jobId <jobId>
```

docker

```
docker run -it \
-v "$(echo $HOME)"/.razor:/root/.razor \
razornetwork/razor-go:latest \
deleteOverride --jobId <jobId>
```

Example:

```
$ ./razor deleteOverride --jobId 2
```

### Set Config

There are a set of parameters that are configurable. These include:
Expand Down Expand Up @@ -752,6 +701,94 @@ docker run -it --network razor_network\
razornetwork/razor-go:latest \
setConfig --exposeMetrics 2112
```

### Override Job and Adding Your Custom Jobs

Jobs URLs are a placeholder for where to fetch values from. There is a chance that these URLs might either fail, or get razor nodes blacklisted, etc.
ashish10677 marked this conversation as resolved.
Show resolved Hide resolved
You can override the existing job and also add your custom jobs by adding `assets.json` file in `.razor` directory so that razor-nodes can fetch data directly from the provided jobs.

Shown below is an example of how your `assets.json` file should be -
```
{
"assets": {
"collection": {
"ethCollectionMean": {
"power": 2,
"official jobs": {
"1": {
"URL": "https://data.messari.io/api/v1/assets/eth/metrics",
"selector": "[`data`][`market_data`][`price_usd`]",
"power": 2,
"weight": 2
},
},
"custom jobs": [
{
"URL": "https://api.lunarcrush.com/v2?data=assets&symbol=ETH",
"selector": "[`data`][`0`][`price`]",
"power": 3,
"weight": 2
},
]
}
}
}
}
```

Breaking down into components
- The existing jobs that you want to override should be included in `official jobs` and fields like URL, selector should be replaced with your provided inputs respectively.

In the above example for the collection `ethCollectionMean`, job having `jobId:1` is override by provided URL, selector, power and weight.
```
"official jobs": {
"1": {
"URL": "https://data.messari.io/api/v1/assets/eth/metrics",
"selector": "[`data`][`market_data`][`price_usd`]",
"power": 2,
"weight": 2
},
```

- Additional jobs tha you want to add to a collection should be added in `custom jobs` field with their respective URLs and selectors.
ashish10677 marked this conversation as resolved.
Show resolved Hide resolved

In the above example for the collection `ethCollectionMean`, new custom job having URL `https://api.lunarcrush.com/v2?data=assets&symbol=ETH` is added.
```
"custom jobs": [
{
"URL": "https://api.lunarcrush.com/v2?data=assets&symbol=ETH",
"selector": "[`data`][`0`][`price`]",
"power": 3,
"weight": 2
},
]
```

### Delete override
ashish10677 marked this conversation as resolved.
Show resolved Hide resolved

The overridden jobs can be deleted using `deleteOverride` command.

razor cli

```
$ ./razor deleteOverride --jobId <jobId>
```

docker

```
docker run -it \
-v "$(echo $HOME)"/.razor:/root/.razor \
razornetwork/razor-go:latest \
deleteOverride --jobId <jobId>
```

Example:

```
$ ./razor deleteOverride --jobId 2
```

### Contribute to razor-go

We would really appreciate your contribution. To see our [contribution guideline](https://github.com/razor-network/razor-go/blob/main/.github/CONTRIBUTING.md)
Expand Down
2 changes: 0 additions & 2 deletions cmd/interface.go
Expand Up @@ -287,8 +287,6 @@ type UtilsCmdInterface interface {
ExecuteUpdateCommission(*pflag.FlagSet)
UpdateCommission(types.Configurations, *ethclient.Client, types.UpdateCommissionInput) error
GetBiggestStakeAndId(*ethclient.Client, string, uint32) (*big.Int, uint32, error)
ExecuteOverrideJob(*pflag.FlagSet)
OverrideJob(*types.StructsJob) error
ExecuteDeleteOverrideJob(*pflag.FlagSet)
DeleteOverrideJob(uint16) error
StakeCoins(types.TransactionOptions) (common.Hash, error)
Expand Down
19 changes: 0 additions & 19 deletions cmd/mocks/utils_cmd_interface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 0 additions & 73 deletions cmd/overrideJob.go

This file was deleted.