-
Notifications
You must be signed in to change notification settings - Fork 5
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
Conversation
@@ -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. |
There was a problem hiding this comment.
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.`); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this 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 😅
ff8f1da
to
6c12747
Compare
Closes #113
Rationale
I implemented the error handling as the issue says. As I was changing the
multicallBeaconValues
andgetUpdatableFeeds
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.