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

Fix RPC timeouts #76

Merged
merged 2 commits into from
Sep 7, 2023
Merged

Fix RPC timeouts #76

merged 2 commits into from
Sep 7, 2023

Conversation

Adamantios
Copy link
Collaborator

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.

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.
Comment on lines +94 to +95
"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}."
Copy link
Collaborator Author

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.

Comment on lines 63 to 65
answerFinalizedTimestamp_not: null,
creationTimestamp_gt: "${from_timestamp}",
isPendingArbitration: false
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 only get trades from_timestamp old.

Comment on lines -187 to +192
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)
Copy link
Collaborator Author

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)
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeap, exactly.

Comment on lines +90 to +108
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}"
)
Copy link
Collaborator Author

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).

@Adamantios Adamantios merged commit 3384c2a into main Sep 7, 2023
6 checks passed
@Adamantios Adamantios deleted the fix/rpc-timeout branch September 7, 2023 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants