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/main #283

Merged
merged 10 commits into from
Sep 30, 2024
Merged

Refactor/main #283

merged 10 commits into from
Sep 30, 2024

Conversation

bewakes
Copy link
Contributor

@bewakes bewakes commented Sep 11, 2024

Description

This PR cleans up main.rs. Basically refactors huge main_inner with manageable helper functions. Also introduces a ManagerContext that hold various managers and handlers. It's not used by any other modules right now, just the main. Plan is to make it usable by others as well in future.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature/Enhancement (non-breaking change which adds functionality or enhances an existing one)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactor

Checklist

  • I have performed a self-review of my code.
  • I have commented my code where necessary.
  • I have updated the documentation if needed.
  • My changes do not introduce new warnings.
  • I have added tests that prove my changes are effective or that my feature works.
  • New and existing tests pass with my changes.

Related Issues

@bewakes
Copy link
Contributor Author

bewakes commented Sep 11, 2024

I had kind of hoped I could place the ManagerContext somewhere common, but the way it bundles things right now, it is not immediately usable by other modules. I just could not stop starting this.

Copy link

codecov bot commented Sep 11, 2024

Codecov Report

Attention: Patch coverage is 20.82826% with 650 lines in your changes missing coverage. Please review.

Project coverage is 60.68%. Comparing base (261519d) to head (0606e7a).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
sequencer/src/main.rs 0.00% 249 Missing ⚠️
sequencer/src/helpers.rs 0.00% 191 Missing ⚠️
crates/consensus-logic/src/duty/worker.rs 0.00% 39 Missing ⚠️
crates/tasks/src/manager.rs 69.91% 34 Missing ⚠️
sequencer/src/rpc_server.rs 0.00% 33 Missing ⚠️
crates/consensus-logic/src/sync_manager.rs 0.00% 26 Missing ⚠️
crates/btcio/src/writer/task.rs 0.00% 16 Missing ⚠️
crates/db/src/database.rs 61.11% 14 Missing ⚠️
crates/bridge-relay/src/relayer.rs 0.00% 7 Missing ⚠️
crates/sync/src/worker.rs 0.00% 7 Missing ⚠️
... and 13 more
@@            Coverage Diff             @@
##           master     #283      +/-   ##
==========================================
- Coverage   61.03%   60.68%   -0.36%     
==========================================
  Files         213      216       +3     
  Lines       23071    23246     +175     
==========================================
+ Hits        14082    14106      +24     
- Misses       8989     9140     +151     
Files with missing lines Coverage Δ
crates/btcio/src/broadcaster/state.rs 97.64% <100.00%> (ø)
crates/btcio/src/broadcaster/task.rs 87.25% <100.00%> (-0.28%) ⬇️
crates/btcio/src/writer/signer.rs 98.46% <100.00%> (ø)
crates/btcio/src/writer/test_utils.rs 100.00% <100.00%> (ø)
crates/db/src/traits.rs 100.00% <ø> (ø)
crates/rocksdb-store/src/broadcaster/db.rs 100.00% <100.00%> (ø)
crates/rocksdb-store/src/sequencer/db.rs 99.16% <100.00%> (ø)
crates/tasks/src/shutdown.rs 91.66% <100.00%> (ø)
sequencer/src/args.rs 0.00% <ø> (ø)
crates/consensus-logic/src/client_transition.rs 76.30% <0.00%> (ø)
... and 22 more

... and 3 files with indirect coverage changes

Copy link
Member

@storopoli storopoli left a comment

Choose a reason for hiding this comment

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

Some minor nits.

Are all the functions here gonna be used outside?
If yes, then we can keep them all pub otherwise pub(crate).

sequencer/src/helpers.rs Outdated Show resolved Hide resolved
sequencer/src/helpers.rs Outdated Show resolved Hide resolved
sequencer/src/helpers.rs Outdated Show resolved Hide resolved
sequencer/src/helpers.rs Show resolved Hide resolved
sequencer/src/helpers.rs Show resolved Hide resolved
sequencer/src/helpers.rs Outdated Show resolved Hide resolved
sequencer/src/helpers.rs Outdated Show resolved Hide resolved
sequencer/src/main.rs Outdated Show resolved Hide resolved
sequencer/src/main.rs Show resolved Hide resolved
sequencer/src/main.rs Outdated Show resolved Hide resolved
@storopoli storopoli mentioned this pull request Sep 12, 2024
11 tasks
Copy link
Contributor

@delbonis delbonis left a comment

Choose a reason for hiding this comment

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

Good start but we should take this opportunity to break down the components into more distinct modules, see comment.

sequencer/src/helpers.rs Show resolved Hide resolved
sequencer/src/helpers.rs Outdated Show resolved Hide resolved
@bewakes bewakes marked this pull request as draft September 19, 2024 12:37
@sapinb sapinb marked this pull request as ready for review September 27, 2024 11:46
@sapinb
Copy link
Contributor

sapinb commented Sep 27, 2024

I've mostly done renames to make them more understandable.
Also, TaskManager spawns require tasks to return anyhow::Error<()> to remove the unwraps()

@delbonis We can break down the init better in another PR. I'm taking this one to be partly cleanup before the initial release.

Also, asking for a speedy review. Dont know how many rebases I've already done here.

@storopoli
Copy link
Member

The rebases must have been a PITA.
I was nit-picking the anyhows but I gave up. Let's track that into a ticket.

We need a new rebase.
I am OK with merging this, @delbonis?

delbonis
delbonis previously approved these changes Sep 27, 2024
Copy link
Contributor

@delbonis delbonis left a comment

Choose a reason for hiding this comment

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

Yeah we're not really done with all the changes we want to perform here but any improvement is good.

@delbonis
Copy link
Contributor

^ These comments are for future work when we revisit this.

Bibek Pandey and others added 10 commits September 30, 2024 11:27
Copy link
Contributor

@Rajil1213 Rajil1213 left a comment

Choose a reason for hiding this comment

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

Approving based on previous comments.

@sapinb sapinb dismissed storopoli’s stale review September 30, 2024 07:02

will be resolved in another PR

@sapinb sapinb merged commit 560aa5b into master Sep 30, 2024
16 of 17 checks passed
@bewakes bewakes deleted the refactor/main branch October 1, 2024 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants