-
Notifications
You must be signed in to change notification settings - Fork 2
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
Additional rpcs #535
base: main
Are you sure you want to change the base?
Additional rpcs #535
Conversation
Codecov ReportAttention: Patch coverage is
@@ Coverage Diff @@
## main #535 +/- ##
==========================================
- Coverage 57.33% 57.13% -0.20%
==========================================
Files 309 308 -1
Lines 31510 31584 +74
==========================================
- Hits 18067 18047 -20
- Misses 13443 13537 +94
|
Also should take a look at STR-697, as this overlaps. |
0885748
to
14a9619
Compare
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.
As a rule of thumb, if implementing some feature involves reaching down multiple layers and adding new functionality deep down, then either some more discussion is needed to properly scope the ticket and design the new functionality better or there's a misunderstanding somewhere.
- strata_getBlockById - strata_getBlocksAtIdx - strata_blockNumber - strata_getLastChainstateIdx - strata_getLastClientStateIdx - strata_getClientStateAtIdx TODO: - strata_getLastBroadcastEntry - strata_getBroadcastEntryByIdx - strate_getChainstateAtIdx
* strata_getLastBroadcastEntry * strata_getBroadcastEntryByIdx * strata_getChainstateAtIdx
* removed functionally duplicating rpcs * exposed L2Block through debug namespace
fix: reconstruction of state at rpc_server instead of fetching using db fix: get_broadcast_entry_by_idx, mistakenly txid was used to fetch, now corrected
90abdc6
to
ebabc76
Compare
ebabc76
to
5b5d5fe
Compare
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, minor nits.
#[method(name = "strata_getLastBroadcastEntry")] | ||
async fn get_last_broadcast_entry(&self) -> RpcResult<Option<L1TxEntry>>; | ||
|
||
/// Get the broadcast entry by its id |
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.
/// Get the broadcast entry by its id | |
/// Get the broadcast entry by its idx |
#[method(name = "getChainstateAtIdx")] | ||
async fn get_chainstate_at_idx(&self, idx: u64) -> RpcResult<Option<RpcChainState>>; | ||
|
||
/// Get the ClientState at a certain index | ||
#[method(name = "getClientStateAtIdx")] | ||
async fn get_clientstate_at_idx(&self, idx: u64) -> RpcResult<Option<ClientState>>; |
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.
Should these also be a part of debug RPC?
Also, would it make sense to have a new type RpcClientState
instead of exposing the ClientState
if this is not a part of debug RPC?
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.
I think it does make sense to have them in debug_. The notion behind types Rpc* is due to Serialization trait not being derived for those structs or to have a stripped down version of the struct. If we move these to debug then this should not be an issue.
cc: @delbonis
@@ -82,6 +82,14 @@ impl L1BroadcastDatabase for L1BroadcastDb { | |||
))) | |||
} | |||
} | |||
|
|||
fn get_last_broadcast_entry(&self) -> DbResult<Option<L1TxEntry>> { |
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.
We should also add a corresponding unit test for this.
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.
also, feels like the name should be get_last_tx_entry
?
} | ||
|
||
async fn get_broadcast_entry_by_idx(&self, idx: u64) -> RpcResult<Option<L1TxEntry>> { | ||
let broadcast_handle = self.broadcast_handle.clone(); |
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.
Probably don't need to clone here and above?
.get_block_async(&block_id) | ||
.await | ||
.map_err(Error::Db)? | ||
.map(|b| b.block().clone()); |
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.
Not sure but maybe we don't need a clone here?
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.
.block() returns reference so it's needed in this case.
#[async_trait] | ||
impl StrataDebugApiServer for StrataDebugRpcImpl { | ||
async fn get_block_by_id(&self, block_id: L2BlockId) -> RpcResult<Option<L2Block>> { | ||
let l2_block_manager = self.l2_block_manager.clone(); |
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.
And here?
Description
These additional rpcs are aimed to be helpful for debugging purpose.
Type of Change
Notes to Reviewers
Looking forward to get suggestions on fields to be exposed from L2Block::body and ChainState.
Checklist
Related Issues
STR-801