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

refactor(conductor)!: use HTTP to periodically poll Celestia heights #852

Merged
merged 1 commit into from
Apr 9, 2024

Conversation

SuperFluffy
Copy link
Member

@SuperFluffy SuperFluffy commented Mar 20, 2024

Summary

Replaces the websocket subscription to get the latest Celestia heights by a HTTP fetch running periodically.

Background

Websocket adds complexity for questionable gain. Tests in particular are much more complex to set up, but also for normal operation disconnects and resubscriptions need to be handled explicitly because websocket does not have a reconnect mechanism.

This PR essentially comes full circle, removing every last trace of websocket again.

Changes

  • Replace the websocket subscription by an interval stream + HTTP fetch (not calling this GET because this is still JSONRPC dong a POST)
  • Removes the ASTRIA_CONDUCTOR_CELESTIA_NODE_WEBSOCKET_URL config
  • Adds the ASTRIA_CONDUCTOR_CELESTIA_BLOCK_TIME_MS config which takes an integer representing the duration in milliseconds between two successive Celestia block heights.
  • Update charts to reflect the env var changes

Testing

Will be tested using blackbox tests and smoke tests (out of scope of this PR)

Breaking Changelist

  • Removed ASTRIA_CONDUCTOR_CELESTIA_NODE_WEBSOCKET_URL
  • Added ASTRIA_CONDUCTOR_CELESTIA_BLOCK_TIME_MS

@github-actions github-actions bot added the conductor pertaining to the astria-conductor crate label Mar 20, 2024
@SuperFluffy SuperFluffy force-pushed the superfluffy/purge-websockets branch from 919630f to fb789c4 Compare March 20, 2024 22:33
@SuperFluffy SuperFluffy changed the title refactor(conductor)!: use HTTP RPC to peridiocally poll Celestia heights refactor(conductor)!: use HTTP to periodically poll Celestia heights Mar 20, 2024
@SuperFluffy SuperFluffy force-pushed the superfluffy/purge-websockets branch from fb789c4 to 23e1499 Compare March 26, 2024 13:44
@github-actions github-actions bot added the cd label Mar 26, 2024
@SuperFluffy SuperFluffy marked this pull request as ready for review April 2, 2024 15:07
@SuperFluffy SuperFluffy requested review from a team, joroshiba and noot as code owners April 2, 2024 15:07
@SuperFluffy SuperFluffy force-pushed the superfluffy/purge-websockets branch 4 times, most recently from 9ca74ae to e1c08f6 Compare April 4, 2024 12:20
@SuperFluffy SuperFluffy requested a review from Fraser999 as a code owner April 4, 2024 12:20
let mut interval = tokio::time::interval(poll_period);
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
LatestHeightStream {
inner: IntervalStream::new(interval).then(f),
Copy link
Collaborator

Choose a reason for hiding this comment

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

did not know about this, very cool

.boxed()
});
let mut interval = tokio::time::interval(poll_period);
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
Copy link
Collaborator

Choose a reason for hiding this comment

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

skipping is ok b/c conductor will fetch all blocks if a few heights are missed in the stream right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, so say the last block fetched is 10 and the latest celestia height we observed is 10 - in this case no new blocks will be fetched.

If the stream fails for 9 consecutive heights but then 10th one succeeds, then the latest observed height jumps from 10 to 20. In that moment the stream schedules 11 to 20 one after the other.

Copy link
Collaborator

@noot noot left a comment

Choose a reason for hiding this comment

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

looks good!

@SuperFluffy SuperFluffy force-pushed the superfluffy/purge-websockets branch from e1c08f6 to 730e03a Compare April 9, 2024 15:09
@SuperFluffy SuperFluffy enabled auto-merge April 9, 2024 15:11
@SuperFluffy SuperFluffy added this pull request to the merge queue Apr 9, 2024
Merged via the queue into main with commit 0124b57 Apr 9, 2024
36 checks passed
@SuperFluffy SuperFluffy deleted the superfluffy/purge-websockets branch April 9, 2024 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cd conductor pertaining to the astria-conductor crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants