Skip to content

Commit

Permalink
Include deployment_id in the heartbeat payload (#1689)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcroote authored Mar 22, 2023
1 parent de936ce commit 18fe3d0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/purple-colts-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@api3/airnode-node': minor
---

Include deployment_id in the heartbeat payload
2 changes: 1 addition & 1 deletion packages/airnode-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ src/
│ └── verification/ # Request verification
├── handlers/ # "Pipeline" type modules that generally serve as entry points
├── providers/ # Provider workers and state
├── reporting/ # Heartbeat implemenetation
├── reporting/ # Heartbeat implementation
├── requests/ # Generic modules applicable to different blockchains
├── utils/ # General utility functions
└── workers/ # Utility function that allow for "forking"
Expand Down
9 changes: 7 additions & 2 deletions packages/airnode-node/src/reporting/heartbeat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe('reportHeartbeat', () => {
timestamp: expectedTimestamp,
stage: state.config.nodeSettings.stage,
cloud_provider: state.config.nodeSettings.cloudProvider.type,
deployment_id: state.settings.deploymentId,
http_gateway_url: 'http://localhost:3000/http-data',
http_signed_data_gateway_url: 'http://localhost:3000/http-signed-data',
oev_gateway_url: 'http://localhost:3000/sign-oev',
Expand Down Expand Up @@ -81,6 +82,7 @@ describe('reportHeartbeat', () => {
timestamp: expectedTimestamp,
stage: state.config.nodeSettings.stage,
cloud_provider: state.config.nodeSettings.cloudProvider.type,
deployment_id: state.settings.deploymentId,
http_gateway_url: 'http://localhost:3000/http-data',
http_signed_data_gateway_url: 'http://localhost:3000/http-signed-data',
oev_gateway_url: 'http://localhost:3000/sign-oev',
Expand Down Expand Up @@ -191,6 +193,7 @@ describe('reportHeartbeat', () => {
timestamp: expectedTimestamp,
stage: state.config.nodeSettings.stage,
cloud_provider: state.config.nodeSettings.cloudProvider.type,
deployment_id: state.settings.deploymentId,
region,
http_gateway_url: httpGatewayUrl,
http_signed_data_gateway_url: httpSignedDataGatewayUrl,
Expand Down Expand Up @@ -227,6 +230,7 @@ describe('reportHeartbeat', () => {
timestamp: expectedTimestamp,
stage: state.config.nodeSettings.stage,
cloud_provider: state.config.nodeSettings.cloudProvider.type,
deployment_id: state.settings.deploymentId,
http_gateway_url: 'http://localhost:8765/http-data',
http_signed_data_gateway_url: 'http://localhost:8765/http-signed-data',
oev_gateway_url: 'http://localhost:8765/sign-oev',
Expand Down Expand Up @@ -254,12 +258,13 @@ describe('reportHeartbeat', () => {
});
});

describe('signHearbeat', () => {
describe('signHeartbeat', () => {
const airnodeAddress = fixtures.getAirnodeWallet().address;
const heartbeatPayload = JSON.stringify({
timestamp: expectedTimestamp,
stage: 'test',
cloud_provider: 'local',
deployment_id: 'local02cce763',
http_gateway_url: httpGatewayUrl,
http_signed_data_gateway_url: httpSignedDataGatewayUrl,
oev_gateway_url: oevGatewayUrl,
Expand All @@ -270,7 +275,7 @@ describe('reportHeartbeat', () => {
const signerAddress = ethers.utils.verifyMessage(heartbeatPayload, signature);

expect(signature).toEqual(
'0x3b705a37aa27173a0fbb2d270d5d827fc6493168515eae05cd9fb60e89399a272726f7f01b261a8e01e9cffa7506369db5c409e6d34f425fde1810046d8376d21c'
'0x7c0415f3e5d120306c0a810626289abec1aad5fcf99fd68e0dbe9f8625811a1220f99205ead02ed6836af6184699745a9e73fbb920186cfd91bb7935df230eec1c'
);
expect(signerAddress).toEqual(airnodeAddress);
});
Expand Down
3 changes: 2 additions & 1 deletion packages/airnode-node/src/reporting/heartbeat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const signHeartbeat = (heartbeatPayload: string) => {
};

export async function reportHeartbeat(state: CoordinatorState): Promise<PendingLog[]> {
const { config } = state;
const { config, settings } = state;
const {
nodeSettings: { heartbeat, cloudProvider, stage },
} = config;
Expand All @@ -65,6 +65,7 @@ export async function reportHeartbeat(state: CoordinatorState): Promise<PendingL
timestamp,
stage,
cloud_provider: cloudProvider.type,
deployment_id: settings.deploymentId,
...(cloudProvider.type !== 'local' ? { region: cloudProvider.region } : {}),
...(httpGatewayUrl ? { http_gateway_url: httpGatewayUrl } : {}),
...(httpSignedDataGatewayUrl ? { http_signed_data_gateway_url: httpSignedDataGatewayUrl } : {}),
Expand Down

0 comments on commit 18fe3d0

Please sign in to comment.