-
Notifications
You must be signed in to change notification settings - Fork 317
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
Add helper for fetching timebounds #249
Conversation
The idea is great but I'm wondering if Horizon server is the best place to check the time. There is no guarantee that it has a correct time set (all timestamps during ingestion are actually taken from ledger headers so Horizon can work correctly even if time is set incorrectly). I think we should probably use Stellar-Core server time and expose it in Horizon root. Unfortunately, it doesn't seem to be exposed currently. |
@bartekn That does sound better. How much does Horizon's timestamp vary? IMO this feature only has to be better than user local time to be worth it, and user local time is a complete mess. I would guess it's right about 90% of time. If Horizon is right 91+% of the time, this seems better, and we can change the underlying data source to a 99% correct source in a later update. |
What I wanted to say is that it'll be probably fine in most cases however it's not guaranteed whereas in core, if the timestamp is not correct, it will simply go out of sync with the network. This is probably good as the first iteration but the final solution should use Stellar-Core's time, imho. |
Yeah, I agree this should use Core within one or two releases. |
My take is that running a server with incorrect time and expecting services on it to work is pretty unrealistic. It's cool that Horizon (maybe) works now with a clock that's off, but it's safe to make it a requirement that the clock be correct (at least to within 1 sec). So I'd just leave it as is. |
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.
Looks good, just minor comments.
Addresses #232.
(1) Add an axios interceptor that tracks the server's reported time from headers
(2) Add a function,
ServerSdk.Server.prototype.fetchTimebounds(seconds: Number)
, that returns atimebounds
object forTransactionBuilder
based on the server time. If no server time is recorded locally, or the recorded time is older than 5 minutes, it'll attempt to go to the network; if THAT fails, use the local time.