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

Remove airnode address from template verification #1037

Merged
merged 4 commits into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/stale-beers-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@api3/airnode-node': patch
---

Remove airnode address from templateId verification
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('initializeProvider', () => {
sponsorWalletAddress: '0x91Fa5bf7FE3cF2a8970B031b1EB6f824fFe228BE',
encodedParameters:
'0x317300000000000000000000000000000000000000000000000000000000000066726f6d000000000000000000000000000000000000000000000000000000004554480000000000000000000000000000000000000000000000000000000000',
id: '0x894580d6cffd205170373f9b95adfe58b65d63f273bb9945e81fa5f0d7901ffe',
id: '0x6229170487af5555b0756bec5bc7f789818c00e8744f4026edcd5bb438a87fb3',
endpointId: '0x13dea3311fe0d6b84f4daeab831befbc49e19e6494c41e9e065a09c3c68f43b6',
fulfillAddress: '0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512',
fulfillFunctionId: '0x7c1de7e1',
Expand All @@ -70,9 +70,9 @@ describe('initializeProvider', () => {
encodedParameters:
'0x3173737373000000000000000000000000000000000000000000000000000000746f00000000000000000000000000000000000000000000000000000000000055534400000000000000000000000000000000000000000000000000000000005f74797065000000000000000000000000000000000000000000000000000000696e7432353600000000000000000000000000000000000000000000000000005f70617468000000000000000000000000000000000000000000000000000000726573756c7400000000000000000000000000000000000000000000000000005f74696d657300000000000000000000000000000000000000000000000000003130303030300000000000000000000000000000000000000000000000000000',
endpointId: '0x13dea3311fe0d6b84f4daeab831befbc49e19e6494c41e9e065a09c3c68f43b6',
id: '0xb3df2ca7646e7823c18038ed320ae3fa29bcd7452fdcd91398833da362df1b46',
id: '0x330d8d77953d56206224f51fb08bebb4e253097bf59c126baa4da8f909ef27ec',
},
templateId: '0xb3df2ca7646e7823c18038ed320ae3fa29bcd7452fdcd91398833da362df1b46',
templateId: '0x330d8d77953d56206224f51fb08bebb4e253097bf59c126baa4da8f909ef27ec',
type: 'template',
},
{
Expand Down
8 changes: 4 additions & 4 deletions packages/airnode-node/src/evm/requests/api-calls.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('initialize (ApiCall)', () => {
fulfillFunctionId: '0x7c1de7e1',
encodedParameters:
'0x317300000000000000000000000000000000000000000000000000000000000066726f6d000000000000000000000000000000000000000000000000000000004554480000000000000000000000000000000000000000000000000000000000',
id: '0x894580d6cffd205170373f9b95adfe58b65d63f273bb9945e81fa5f0d7901ffe',
id: '0x6229170487af5555b0756bec5bc7f789818c00e8744f4026edcd5bb438a87fb3',
metadata: {
address: '0x5FbDB2315678afecb367f032d93F642f64180aa3',
blockNumber: 10716082,
Expand All @@ -38,7 +38,7 @@ describe('initialize (ApiCall)', () => {
},
parameters: {},
requestCount: '1',
templateId: '0xb3df2ca7646e7823c18038ed320ae3fa29bcd7452fdcd91398833da362df1b46',
templateId: '0x330d8d77953d56206224f51fb08bebb4e253097bf59c126baa4da8f909ef27ec',
type: 'template',
});
});
Expand Down Expand Up @@ -164,7 +164,7 @@ describe('mapRequests (ApiCall)', () => {
fulfillFunctionId: '0x7c1de7e1',
encodedParameters:
'0x317300000000000000000000000000000000000000000000000000000000000066726f6d000000000000000000000000000000000000000000000000000000004554480000000000000000000000000000000000000000000000000000000000',
id: '0x894580d6cffd205170373f9b95adfe58b65d63f273bb9945e81fa5f0d7901ffe',
id: '0x6229170487af5555b0756bec5bc7f789818c00e8744f4026edcd5bb438a87fb3',
metadata: {
address: '0x5FbDB2315678afecb367f032d93F642f64180aa3',
blockNumber: 10716082,
Expand All @@ -174,7 +174,7 @@ describe('mapRequests (ApiCall)', () => {
},
parameters: { from: 'ETH' },
requestCount: '1',
templateId: '0xb3df2ca7646e7823c18038ed320ae3fa29bcd7452fdcd91398833da362df1b46',
templateId: '0x330d8d77953d56206224f51fb08bebb4e253097bf59c126baa4da8f909ef27ec',
type: 'template',
},
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import { verifyTemplateId } from '../../api';
// TODO: Move to call-api.test.ts
describe('verify', () => {
const validTemplateFields = {
airnodeAddress: '0x5FbDB2315678afecb367f032d93F642f64180aa3',
endpointId: '0x2f3a3adf6daf5a3bb00ab83aa82262a6a84b59b0a89222386135330a1819ab48',
encodedParameters: '0x6466726f6d63455448',
};

const TEMPLATE_ID = '0xb2f063157fcc3c986daf4c2cf1b8ac8b8843f2b1a54c5de5e1ebdf12fb85a927';
const TEMPLATE_ID = '0xe5d99287b5a870c3453bc0b42769c6f37cf4a3143890e9c34753181171fac842';

it('returns API calls not linked to templates', () => {
const aggregatedApiCall = fixtures.buildAggregatedRegularApiCall({ templateId: null });
Expand Down Expand Up @@ -67,7 +66,6 @@ describe('verify', () => {
});
const config = fixtures.buildConfig();
const invalidFields = {
airnodeAddress: '0x69e2B095fbAc6C3f9E528Ef21882b86BF1595181',
endpointId: '0x05218bc3e2497776d24b7da2890e12c910d07ce647cc45bd565cbb167e620df3',
encodedParameters: '0x1234',
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ interface ValidatedField {

function getTemplateIdValidationFields(template: ApiCallTemplateWithoutId): ValidatedField[] {
return [
{ type: 'address', value: template.airnodeAddress },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @acenolaza is correct. The getExpectedTemplateId function is used in api/index.ts (https://github.com/api3dao/airnode/blob/master/packages/airnode-node/src/api/index.ts#L149) both for signed data gateway requests but also regular Airnode RRP requests. That's why you had to change tests everywhere, not just the ones for callApi. I think this change breaks the Airnode RRP. We need two different template ID derivation functions, one for Airnode RRP (v0 contracts) and one for signed data gateway (v1 contracts).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you prefer to have two separate functions, or we could pass the request type (regular/http-signed-gateway) into getExpectedTemplateId and return based on that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think two separate functions will result in a nicer code.

{ type: 'bytes32', value: template.endpointId },
{ type: 'bytes', value: template.encodedParameters },
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as api from '../api';
import * as fixtures from '../../test/fixtures';

const ENDPOINT_ID = '0x13dea3311fe0d6b84f4daeab831befbc49e19e6494c41e9e065a09c3c68f43b6';
const TEMPLATE_ID = '0x600975681b98422eee1146d4b835a8103689ae4cddb76069925a929caf0eb79f';
const TEMPLATE_ID = '0xaa1525fe964092a826934ff09c75e1db395b947543a4ca3eb4a19628bad6c6d5';

function buildConfigWithEndpoint(endpoint?: Endpoint) {
const endpoints = endpoint ? [endpoint] : [];
Expand Down
4 changes: 2 additions & 2 deletions packages/airnode-node/src/handlers/start-coordinator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ describe('startCoordinator', () => {
// API call was submitted
expect(fulfillMock).toHaveBeenCalledTimes(1);
expect(fulfillMock).toHaveBeenCalledWith(
'0x894580d6cffd205170373f9b95adfe58b65d63f273bb9945e81fa5f0d7901ffe',
'0x6229170487af5555b0756bec5bc7f789818c00e8744f4026edcd5bb438a87fb3',
'0xA30CA71Ba54E83127214D3271aEA8F5D6bD4Dace',
'0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512',
'0x7c1de7e1',
'0x0000000000000000000000000000000000000000000000000000000002a5213d',
'0x69567b16514c2b799597247462cc6c3d9ac9dce88c0bc97c17db45dfb572cacb0fc7b38b2a73cf1fd78279251e5ef75b5e6fb06f4b0f0d023c4b215609e2e38f1b',
'0xe6f50a61d61d0b0584a8190eda4f4df491d2853e21a91c6b6b62fee7a4baf44d379d96768b4ab3b31e4697a7942c26ee4e4fdeb66db03b2500f897252915616e1b',
{ ...gasTarget, nonce: 212 }
);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/airnode-node/test/fixtures/aggregated-api-call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ export function buildAggregatedHttpSignedDataApiCall(
id: '0xb56b66dc089eab3dc98672ea5e852488730a8f76621fd9ea719504ea205980f8',
oisTitle: 'Currency Converter API',
parameters: { from: 'ETH' },
templateId: '0x600975681b98422eee1146d4b835a8103689ae4cddb76069925a929caf0eb79f',
templateId: '0xaa1525fe964092a826934ff09c75e1db395b947543a4ca3eb4a19628bad6c6d5',
template: {
airnodeAddress: '0xA30CA71Ba54E83127214D3271aEA8F5D6bD4Dace',
endpointId: 'endpointId',
id: '0x600975681b98422eee1146d4b835a8103689ae4cddb76069925a929caf0eb79f',
id: '0xaa1525fe964092a826934ff09c75e1db395b947543a4ca3eb4a19628bad6c6d5',
encodedParameters:
'0x317373730000000000000000000000000000000000000000000000000000000066726f6d0000000000000000000000000000000000000000000000000000000045544800000000000000000000000000000000000000000000000000000000005f74797065000000000000000000000000000000000000000000000000000000696e7432353600000000000000000000000000000000000000000000000000005f706174680000000000000000000000000000000000000000000000000000007072696365000000000000000000000000000000000000000000000000000000',
},
Expand Down
6 changes: 3 additions & 3 deletions packages/airnode-node/test/fixtures/evm/event-logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export function buildMadeTemplateRequest(overrides?: Partial<Log>): Log {
transactionIndex: 0,
removed: false,
address: '0x5FbDB2315678afecb367f032d93F642f64180aa3',
data: '0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000007a69000000000000000000000000e7f1725e7734ce288f8367e1bb143e90bb3f0512b3df2ca7646e7823c18038ed320ae3fa29bcd7452fdcd91398833da362df1b4600000000000000000000000061648b2ec3e6b3492e90184ef281c2ba28a675ec00000000000000000000000091fa5bf7fe3cf2a8970b031b1eb6f824ffe228be000000000000000000000000e7f1725e7734ce288f8367e1bb143e90bb3f05127c1de7e10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000060317300000000000000000000000000000000000000000000000000000000000066726f6d000000000000000000000000000000000000000000000000000000004554480000000000000000000000000000000000000000000000000000000000',
data: '0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000007a69000000000000000000000000e7f1725e7734ce288f8367e1bb143e90bb3f0512330d8d77953d56206224f51fb08bebb4e253097bf59c126baa4da8f909ef27ec00000000000000000000000061648b2ec3e6b3492e90184ef281c2ba28a675ec00000000000000000000000091fa5bf7fe3cf2a8970b031b1eb6f824ffe228be000000000000000000000000e7f1725e7734ce288f8367e1bb143e90bb3f05127c1de7e10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000060317300000000000000000000000000000000000000000000000000000000000066726f6d000000000000000000000000000000000000000000000000000000004554480000000000000000000000000000000000000000000000000000000000',
topics: [
'0xeb39930cdcbb560e6422558a2468b93a215af60063622e63cbb165eba14c3203',
'0x000000000000000000000000a30ca71ba54e83127214d3271aea8f5d6bd4dace',
'0x894580d6cffd205170373f9b95adfe58b65d63f273bb9945e81fa5f0d7901ffe',
'0x6229170487af5555b0756bec5bc7f789818c00e8744f4026edcd5bb438a87fb3',
],
transactionHash: '0x40b93a1e81c7162460af066be96266ff692515a2f6b54bd622aa9f82ee00670f',
logIndex: 0,
Expand All @@ -35,7 +35,7 @@ export function buildTemplateFulfilledRequest(overrides?: Partial<Log>): Log {
topics: [
'0xc0977dab79883641ece94bb6a932ca83049f561ffff8d8daaeafdbc1acce9e0a',
'0x000000000000000000000000a30ca71ba54e83127214d3271aea8f5d6bd4dace',
'0x894580d6cffd205170373f9b95adfe58b65d63f273bb9945e81fa5f0d7901ffe',
'0x6229170487af5555b0756bec5bc7f789818c00e8744f4026edcd5bb438a87fb3',
],
transactionHash: '0x6f0a11898efc15d49bdc5c799348f32d36f6b4294e24ff1c51feceeba8953d5f',
logIndex: 1,
Expand Down