Skip to content

Fix error handling and update transaction calldata #119

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

Merged
merged 5 commits into from
Nov 29, 2023
Merged

Conversation

Siegrift
Copy link
Collaborator

Closes #113

Rationale

I implemented the error handling as the issue says. As I was changing the multicallBeaconValues and getUpdatableFeeds I decided to simplify it a bit by avoiding mutation in map/filter but I preserved the logic.

I also noticed that we are incorrectly creating the beacon set update calldata. We need to update the beacon set with all beacons (not just the ones that are updatable). I've added a few tests to guard for this.

@Siegrift Siegrift self-assigned this Nov 28, 2023
@Siegrift Siegrift requested review from aquarat and vponline November 28, 2023 07:30
@@ -48,7 +48,6 @@ export const checkDeviationThresholdExceeded = (
*
* Update transaction with stale data would revert on chain, draining the sponsor wallet. See:
* https://github.com/api3dao/airnode-protocol-v1/blob/dev/contracts/dapis/DataFeedServer.sol#L121
* This can happen if the gateway or Airseeker is down and Airkeeper does the updates instead.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This part of the comment was outdated.

return true;
}
} else {
logger.info(`On-chain timestamp is older than the heartbeat interval.`);

logger.debug(`On-chain timestamp is older than the heartbeat interval.`);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The info level feels to high for this type of information.

value: decodeBeaconValue(signedData.encodedValue)!,
}
: undefined;
const isUpdatable = offChainValue?.timestamp.gt(onChainValue.timestamp);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We do not need to check offChainValue.timestamp.gt(Math.ceil(Date.now() / 1000 + 60 * 60)) because we already check that when we recieve the signed data.

logger.warn(`No active dAPIs found`);
return;
}
// NOTE: We need to explicitly handle the .catch here because it's possible that the promise settles before it's
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This gave me a hard time to debug, but its actually correct. There is a sleep call below. If the promise resolves sooner it is unhandled (because we await it only a few lines below). To address this issue we need to catch the error ourselves.

Copy link
Collaborator

@aquarat aquarat left a comment

Choose a reason for hiding this comment

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

LGTM, very neat, good to have the "bad path" tested 😅

Base automatically changed from fallback-gas-limit to main November 29, 2023 13:30
@Siegrift Siegrift merged commit 8e28e4e into main Nov 29, 2023
@Siegrift Siegrift deleted the fix-error-handling branch November 29, 2023 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix incorrect beacon values multicall error handling
2 participants