-
Notifications
You must be signed in to change notification settings - Fork 19
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
Fix RPC timeouts #76
Fix RPC timeouts #76
Conversation
Only search up to a specific number of days in the past (`redeem_margin_days`) for redeeming positions. This is done to avoid a known timeout limitation of getblock's Gnosis RPCs. Positions for older markets will have to be manually redeemed.
"If the issue persists, try to decrease the value of `redeem_margin_days` " | ||
f"in the agent's configuration, based on the date corresponding to the block number {earliest_block}." |
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.
Advice to the user in case a timeout occurs.
answerFinalizedTimestamp_not: null, | ||
creationTimestamp_gt: "${from_timestamp}", | ||
isPendingArbitration: false |
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 only get trades from_timestamp
old.
query = trades.substitute(creator=safe.lower()) | ||
redeem_margin = self.params.redeem_margin_days * DAY_UNIX | ||
from_timestamp = self.synced_time - redeem_margin | ||
query = trades.substitute(creator=safe.lower(), from_timestamp=from_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.
from_timestamp
is calculated using the synced time minus a configurable margin given in days.
query = trades.substitute(creator=safe.lower()) | ||
redeem_margin = self.params.redeem_margin_days * DAY_UNIX | ||
from_timestamp = self.synced_time - redeem_margin | ||
query = trades.substitute(creator=safe.lower(), from_timestamp=from_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.
I assume the event filter later on is made s.t. the lowest block is used from this response, correct?
I am asking because I don't see changes related to from_block
, or something like that.
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.
Yeap, exactly.
value_enforcement = ( | ||
f"The value needs to be in the exclusive range (0, {GNOSIS_RPC_TIMEOUT_DAYS}) " | ||
f"and manual redeeming has to be performed for markets older than {GNOSIS_RPC_TIMEOUT_DAYS - 1} days." | ||
) | ||
|
||
if redeem_margin_days <= 0: | ||
raise ValueError( | ||
"The margin in days for the redeeming information (`redeem_margin_days`) " | ||
f"cannot be set to {redeem_margin_days} <= 0. {value_enforcement}" | ||
) | ||
if redeem_margin_days >= GNOSIS_RPC_TIMEOUT_DAYS: | ||
raise ValueError( | ||
"Due to a constraint of the Gnosis RPCs, it is not possible to configure the redeeming " | ||
f"information's time window to exceed {GNOSIS_RPC_TIMEOUT_DAYS - 1} days " | ||
f"(currently {redeem_margin_days=}). To clarify, these RPCs experience timeouts " | ||
"when attempting to filter for historical on-chain events. " | ||
"Practical testing of the service has revealed that timeouts consistently occur for blocks " | ||
f"approximately {GNOSIS_RPC_TIMEOUT_DAYS} days old. {value_enforcement}" | ||
) |
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.
Do not allow the margin to be less than 1 or more than GNOSIS_RPC_TIMEOUT_DAYS - 1
(currently 24).
b8ae78e
to
c31c940
Compare
Addresses a known timeout limitation of getblock's Gnosis RPCs.
The service now only searches up to a specific number of days in the past (
redeem_margin_days
) for redeeming positions. Positions for older markets will have to be manually redeemed.