Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.

Commit 7e56356

Browse files
committed
OEV gateway
1 parent 3294963 commit 7e56356

File tree

8 files changed

+231
-1
lines changed

8 files changed

+231
-1
lines changed

.tool-versions

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodejs lts-fermium

docs/airnode/v0.11/grp-providers/guides/build-an-airnode/heartbeat.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ Turn on the optional heartbeat functionality by setting all fields in the
5454
"maxConcurrency": 20,
5555
"corsOrigins": []
5656
},
57+
"oevGateway": {
58+
"enabled": true,
59+
"maxConcurrency": 20,
60+
"corsOrigins": []
61+
},
5762
"logFormat": "json",
5863
"logLevel": "INFO",
5964
"nodeVersion": "0.11.0",
@@ -75,6 +80,7 @@ The table below illustrates the parameters passed to the Heartbeat URL.
7580
| airnode-heartbeat-api-key | header | string |
7681
| http_gateway_url | body | string |
7782
| http_signed_data_gateway_url | body | string |
83+
| oev_gateway_url | body | string |
7884
| cloud_provider | body | string |
7985
| stage | body | string |
8086
| region | body | string |
@@ -91,7 +97,8 @@ Below is an example of what is included in the request body to `heartbeat.url`:
9197
"stage": "2209100913",
9298
"cloud_provider": "aws",
9399
"http_gateway_url": "https://some.aws.http.gateway.url/v1/01234567-abcd-abcd-abcd-012345678abc",
94-
"http_signed_data_gateway_url": "https://some.aws.http.signed.data.gateway.url/v1/01234567-abcd-abcd-abcd-012345678abc"
100+
"http_signed_data_gateway_url": "https://some.aws.http.signed.data.gateway.url/v1/01234567-abcd-abcd-abcd-012345678abc",
101+
"oev_gateway_url": "https://some.aws.oev.gateway.url/v1/01234567-abcd-abcd-abcd-012345678abc"
95102
},
96103
"signature": "0x733f81fa1dffab3188e50ad66c178a22aca3a781d79a1b8daee7828cff31d1443d89efd5a2b1f40fc70953c9c5838cc8d5747374f3cf25d092331ba15b6420651c"
97104
}
@@ -124,6 +131,9 @@ The inner payload's contents are as follows:
124131
<tr>
125132
<td>http_signed_data_gateway_url:</td><td>If HTTP signed data gateway is enabled this is the URL of the gateway you can make HTTP calls against.</td>
126133
</tr>
134+
<tr>
135+
<td>oev_gateway_url:</td><td>If OEV gateway is enabled this is the URL of the gateway you can make HTTP calls against.</td>
136+
</tr>
127137
<tr>
128138
<td>cloud_provider:</td><td>This is the deployment cloud provider.</td>
129139
</tr>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
---
2+
title: OEV Gateway (optional)
3+
docSetName: Airnode v0.11
4+
folder: API Providers > Build an Airnode
5+
basePath: /airnode/v0.11
6+
tags:
7+
---
8+
9+
<TitleSpan>{{$frontmatter.folder}}</TitleSpan>
10+
11+
# {{$frontmatter.title}}
12+
13+
<VersionWarning/>
14+
15+
<TocHeader />
16+
<TOC class="table-of-contents" :include-level="[2,3]" />
17+
18+
OEV gateway is used in the OEV flow to sign the data won in the auction. The
19+
data is signed by the Airnode so that only the searcher who won the auction can
20+
use it to update the data feed.
21+
22+
## Setup
23+
24+
Enable the gateway in the `config.json` file via `nodeSettings.oevGateway`
25+
section.
26+
27+
- **enabled**: A boolean to enable/disable for the gateway.
28+
- **maxConcurrency**: (optional) A number higher than zero that represents the
29+
maximum number of serverless functions serving gateway requests. When omitted,
30+
there is no maximum concurrency set. This field is ignored for Airnode client
31+
gateways.
32+
- **corsOrigins**: A list of allowed origins, `['*']` to allow all origins or an
33+
empty array to disable CORS.
34+
35+
```json
36+
"nodeSettings": {
37+
"cloudProvider": {
38+
"type": "aws",
39+
"region": "us-east-1"
40+
},
41+
"airnodeWalletMnemonic": "${AIRNODE_WALLET_MNEMONIC}",
42+
"heartbeat": {...},
43+
"oevGateway": {
44+
"enabled": true,
45+
"maxConcurrency": 20,
46+
"corsOrigins": []
47+
},
48+
...
49+
},
50+
```
51+
52+
## Gateway URL
53+
54+
The gateway implementation is different depending on how Airnode is deployed.
55+
When deployed on a cloud provider, the serverless gateway is used. Inside
56+
Airnode client, the gateway is implemented via a simple web server inside the
57+
docker container. There are subtle differences in both how the gateways work and
58+
what the gateway URLs look like.
59+
60+
The deployer generates a secret `UUID` path parameter which ensures that the
61+
endpoints are not openly accessible. Therefore, the gateway URL should be kept
62+
secret.
63+
64+
The gateway URL is also available as part of the payload sent from Airnode's
65+
[heartbeat](./heartbeat.md) to your specified heartbeat URL.
66+
67+
### When deployed on a cloud provider
68+
69+
A gateway URL is generated when Airnode is deployed. You can see the URLs
70+
including the secret `UUID` path parameter, displayed on your terminal at the
71+
end of an Airnode deployment using a [Docker image](../../docker/).
72+
73+
### When using Airnode client
74+
75+
Airnode client can be used to run Airnode as a docker container locally. There
76+
is a common web server for the gateway, which is exposed on the host machine.
77+
Doing so will make the gateway API accessible like a regular web server running
78+
on the machine. Note the `PORT` which is exposed as part of the Airnode client
79+
container. See the [Airnode client usage](../../docker/client-image.md#usage)
80+
for more details.
81+
82+
- `http://localhost:<PORT>/sign-oev/01234567-abcd-abcd-abcd-012345678abc` -
83+
Gateway URL for the OEV Gateway
84+
85+
## Usage
86+
87+
In order to execute the processing on the gateway, it needs to receive a
88+
properly constructed HTTP request:
89+
90+
- It must be a `POST` request
91+
- It must contain a `Content-Type` header, set to `application/json`.
92+
- It must contain the following JSON body:
93+
94+
```json
95+
{
96+
"chainId": <CHAIN_ID>,
97+
"dapiServerAddress": <DAPI_SERVER_ADDRESS>,
98+
"oevProxyAddress": <OEV_PROXY_ADDRESS>,
99+
"updateId": <UPDATE_ID>,
100+
"bidderAddress": <BIDDER_ADDRESS>,
101+
"bidAmount": <BID_AMOUNT>,
102+
"signedData": [
103+
{
104+
"airnodeAddress": <AIRNODE_ADDRESS>,
105+
"endpointId": <EDNPOINT_ID>,
106+
"encodedParameters": <ENCODED_PARAMETERS>,
107+
"timestamp": <TIMESTAMP>,
108+
"encodedValue": <ENCODED_VALUE>,
109+
"signature": <SIGNATURE>
110+
},
111+
{
112+
"airnodeAddress": <AIRNODE_ADDRESS>,
113+
"endpointId": <EDNPOINT_ID>,
114+
"encodedParameters": <ENCODED_PARAMETERS>
115+
},
116+
...
117+
]
118+
}
119+
```
120+
121+
where:
122+
123+
- `chainId` - ID of the blockchain where the auction was held.
124+
- `dapiServerAddress` - Blockchain address of the dAPI server contract.
125+
- `oevProxyAddress` - Blockchain address of the proxy data feed contract.
126+
- `updateId` - Auction update ID.
127+
- `bidderAddress` - Blockchain address of the winning searcher.
128+
- `bidAmount` - Bid amount that won the auction.
129+
- `signedData` - A list of beacon data to be signed. It can contain two types:
130+
full beacon data, only beacon metadata
131+
- `airnodeAddress` - Airnode address identifying a beacon
132+
- `endpointId` - Endpoint ID identifying a beacon
133+
- `encodedParameters` - Parameters in their encoded form identifying a beacon
134+
- `timestamp` - UNIX timestamp of the beacon data
135+
- `encodedValue` - Beacon value in its encoded form
136+
- `signature` - Signature of the beacon data
137+
138+
### Example request
139+
140+
```sh
141+
curl \
142+
-X POST \
143+
-H 'Content-Type: application/json' \
144+
-d '{"chainId":1,"dapiServerAddress":"0x...","oevProxyAddress":"0x...","updateId":"0x...","bidderAddress":"0x...","bidAmount":"0x...","signedData":[{"airnodeAddress":"0x...","endpointId":"0x...","encodedParameters":"0x...","timestamp":"16...","encodedValue":"0x...","signature":"0x..."},{"airnodeAddress":"0x...","endpointId":"0x...","encodedParameters":"0x..."}]}' \
145+
'<gatewayUrl>'
146+
```
147+
148+
### Example response
149+
150+
```json
151+
[
152+
{
153+
"timestamp": "16...",
154+
"encodedValue": "0x...",
155+
"signature": "0x..."
156+
},
157+
{
158+
"timestamp": "16...",
159+
"encodedValue": "0x...",
160+
"signature": "0x..."
161+
}
162+
]
163+
```
164+
165+
The gateway will return a list of signed beacon data, signing for each beacon
166+
within the data feed that is served by the given Airnode. There are two elements
167+
that are signed: template ID of the beacon and the OEV update hash, uniqly
168+
identifying given OEV update.
169+
170+
- `timestamp` - UNIX timestamp of the signature
171+
- `encodedValue` - Encoded OEV update value
172+
- `signature` - Signature of the OEV update by Airnode

docs/airnode/v0.11/reference/deployment-files/config-json.md

+30
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,11 @@ An object containing general deployment parameters of an Airnode.
340340
"maxConcurrency": 20,
341341
"corsOrigins": []
342342
},
343+
"oevGateway": {
344+
"enabled": true,
345+
"maxConcurrency": 20,
346+
"corsOrigins": []
347+
},
343348
"logFormat": "json",
344349
"logLevel": "INFO"
345350
}
@@ -483,6 +488,31 @@ set.
483488
An empty array (`[]`) can be used to disable CORS and the wildcard (`['*']`) can
484489
be used to allow all origins.
485490

491+
### `oevGateway`
492+
493+
(required) - OEV gateway is used in the OEV flow to sign the data won in the
494+
auction. See the
495+
[OEV Gateway](../../grp-providers/guides/build-an-airnode/oev-gateway.md)
496+
documentation for more info.
497+
498+
#### `oevGateway.enabled`
499+
500+
(required) - Enable or disable, using `true` or `false`, the OEV gateway.
501+
502+
#### `oevGateway.maxConcurrency`
503+
504+
(required: <span style="font-size:small;color:gray;">
505+
`if oevGateway.enabled is true`</span>) - A number higher than zero representing
506+
the maximum number of serverless functions serving OEV gateway requests running
507+
at the same time. When omitted, there is no maximum concurrency set.
508+
509+
#### `oevGateway.corsOrigins`
510+
511+
(required: <span style="font-size:small;color:gray;">
512+
`if oevGateway.enabled is true`</span>) - A list of allowed origins. An empty
513+
array (`[]`) can be used to disable CORS and the wildcard (`['*']`) can be used
514+
to allow all origins.
515+
486516
### `logFormat`
487517

488518
(required) - The format that will be used to output logs. Either `json` or

docs/airnode/v0.11/reference/examples/config-cloud.json

+5
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@
6262
"maxConcurrency": 20,
6363
"corsOrigins": []
6464
},
65+
"oevGateway": {
66+
"enabled": true,
67+
"maxConcurrency": 20,
68+
"corsOrigins": []
69+
},
6570
"logFormat": "plain",
6671
"logLevel": "INFO",
6772
"nodeVersion": "0.11.0",

docs/airnode/v0.11/reference/examples/config-local.json

+3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
"httpSignedDataGateway": {
5353
"enabled": false
5454
},
55+
"oevGateway": {
56+
"enabled": false
57+
},
5558
"logFormat": "plain",
5659
"logLevel": "INFO",
5760
"nodeVersion": "0.11.0",

docs/airnode/v0.11/reference/templates/config-json.md

+5
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ building a config.json file.
121121
"maxConcurrency": <FILL_NUMBER>,
122122
"corsOrigins": ["<FILL_*>"]
123123
},
124+
"oevGateway": {
125+
"enabled": <FILL_BOOLEAN>,
126+
"maxConcurrency": <FILL_NUMBER>,
127+
"corsOrigins": ["<FILL_*>"]
128+
},
124129
"logFormat": "json",
125130
"logLevel": "INFO",
126131
"nodeVersion": "0.11.0",

docs/airnode/v0.11/sidebar.js

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ module.exports = [
4444
title: 'HTTP Gateways',
4545
path: 'grp-providers/guides/build-an-airnode/http-gateways',
4646
},
47+
{
48+
title: 'OEV Gateway',
49+
path: 'grp-providers/guides/build-an-airnode/oev-gateway',
50+
},
4751
'grp-providers/guides/build-an-airnode/deploying-airnode',
4852
'grp-providers/guides/build-an-airnode/monitoring-airnode',
4953
],

0 commit comments

Comments
 (0)