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: replace homegrown Bitcoin RPC for bitcoincore-rpc-async crate #239

Closed

Conversation

storopoli
Copy link
Member

@storopoli storopoli commented Aug 19, 2024

Description

Replacing our homegrown solution with an off-the-shelf crate,
bitcoincore_rpc_async(https://docs.rs/bitcoincore-rpc-async).

Commits are atomic in a sense that they don't fail on CI and can be read/reviewed in a interdependent basis.

Also tried to improve all the docstrings of the functions that I had to touch.

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

EXP-189
Closes #81.

TODO

  • Figure out how to catch the specific error -27/-25 in btcio/src/writer/broadcast.rs inside the broadcaster_task function.

@storopoli

This comment was marked as resolved.

sequencer/src/l1_reader.rs Outdated Show resolved Hide resolved
@storopoli storopoli force-pushed the EXP-101-migrate-btcio-rpc-to-rust-bitcoincore-rpc branch 3 times, most recently from 762766c to 91259db Compare August 20, 2024 19:12
@storopoli storopoli changed the title refactor: remove btcio rpc traits for bitcoincore-rpc-async refactor: replace homegrown Bitcoin RPC for bitcoincore-rpc-async crate Aug 20, 2024
Copy link

codecov bot commented Aug 20, 2024

Codecov Report

Attention: Patch coverage is 5.09259% with 205 lines in your changes missing coverage. Please review.

Project coverage is 55.36%. Comparing base (1485d2e) to head (d3c653a).

Files Patch % Lines
sequencer/src/main.rs 0.00% 90 Missing ⚠️
crates/btcio/src/rpc/client.rs 0.00% 35 Missing ⚠️
crates/btcio/src/writer/test_utils.rs 5.55% 34 Missing ⚠️
crates/btcio/src/reader/query.rs 0.00% 19 Missing ⚠️
crates/btcio/src/writer/broadcast.rs 0.00% 10 Missing ⚠️
crates/btcio/src/writer/writer_handler.rs 0.00% 9 Missing ⚠️
crates/btcio/src/writer/config.rs 0.00% 2 Missing ⚠️
crates/btcio/src/writer/watcher.rs 0.00% 2 Missing ⚠️
crates/evmexec/src/engine.rs 0.00% 2 Missing ⚠️
crates/btcio/src/writer/builder.rs 75.00% 1 Missing ⚠️
... and 1 more
@@            Coverage Diff             @@
##           master     #239      +/-   ##
==========================================
+ Coverage   54.15%   55.36%   +1.21%     
==========================================
  Files         111      111              
  Lines       11964    11702     -262     
==========================================
  Hits         6479     6479              
+ Misses       5485     5223     -262     
Files Coverage Δ
crates/btcio/src/writer/utils.rs 86.70% <100.00%> (+0.17%) ⬆️
crates/btcio/src/writer/builder.rs 95.64% <75.00%> (+<0.01%) ⬆️
sequencer/src/l1_reader.rs 0.00% <0.00%> (ø)
crates/btcio/src/writer/config.rs 0.00% <0.00%> (ø)
crates/btcio/src/writer/watcher.rs 0.00% <0.00%> (ø)
crates/evmexec/src/engine.rs 68.94% <0.00%> (ø)
crates/btcio/src/writer/writer_handler.rs 40.22% <0.00%> (-0.46%) ⬇️
crates/btcio/src/writer/broadcast.rs 0.00% <0.00%> (ø)
crates/btcio/src/reader/query.rs 0.00% <0.00%> (ø)
crates/btcio/src/writer/test_utils.rs 31.81% <5.55%> (-22.73%) ⬇️
... and 2 more

@storopoli storopoli force-pushed the EXP-101-migrate-btcio-rpc-to-rust-bitcoincore-rpc branch from 91259db to e215e09 Compare August 20, 2024 22:47
Comment on lines +92 to +95
// DEBUG: What the hell is this?
// FIXME: remove me
#[cfg(debug_assertions)]
dbg!(&e);
Copy link
Contributor

Choose a reason for hiding this comment

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

What are you refering to here? The Err(e) block or the cfg(debug_assertions) thing?

Copy link
Member Author

Choose a reason for hiding this comment

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

This will be removed once I figure out the

Figure out how to catch the specific error -27/-25 in btcio/src/writer/broadcast.rs inside the broadcaster_task function.

in the TODO list of the PR description.
It will not be in the finished ready to review state.

Copy link
Contributor

@bewakes bewakes 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 to me.

One thing is that I am not sure if we should split the rpc interfaces to what a reader, signer and publisher might be using. For example, reader does not need to publish/sign transactions, while a signer does not need to publish transactions whereas publisher does not need to sign transactions. All are inside one trait in this PR, but I guess that's fine too. What do you think?

@storopoli
Copy link
Member Author

Yes, I agree that this might be interesting in the future.

I just don't think that the added complexity is worth right now.
Maybe we can add to a ticket later.
I think that unifying everything into a single trait solves the issue right now and keeps the complexity low.

But I might be wrong, there might be something that I am not seeing here...

Along with a bunch of docstrings improvements
Changes to a thin tuple struct wrapper for
`bitcoincore-rpc-async::Client`.
@storopoli storopoli force-pushed the EXP-101-migrate-btcio-rpc-to-rust-bitcoincore-rpc branch from e215e09 to 4331440 Compare August 21, 2024 15:59
@storopoli storopoli mentioned this pull request Aug 21, 2024
11 tasks
@storopoli storopoli force-pushed the EXP-101-migrate-btcio-rpc-to-rust-bitcoincore-rpc branch from a1f1908 to 3664d97 Compare August 21, 2024 22:53
@storopoli storopoli force-pushed the EXP-101-migrate-btcio-rpc-to-rust-bitcoincore-rpc branch from 3664d97 to d3c653a Compare August 21, 2024 23:06
@storopoli
Copy link
Member Author

Currently the tokio runtime in sequencer/main.rs probably has some sort of crazy infinite recursion and we are getting:

thread 'express-rt' has overflowed its stack
fatal runtime error: stack overflow

I am struggling to debug since I cannot force cargo to output any trace in the functional tests.

@storopoli
Copy link
Member Author

The rebase is too painful and effortful. Closing in favor of #245.

@storopoli storopoli closed this Aug 22, 2024
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.

Replace homegrown Bitcoin RPC client with an off-the-shelf one
2 participants