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

Update L1Tx ref types to include multiple proto ops per tx #618

Open
wants to merge 25 commits into
base: STR-807-inscription-changes
Choose a base branch
from

Conversation

bewakes
Copy link
Contributor

@bewakes bewakes commented Jan 20, 2025

Description

This PR does the following:

  1. Add RawProtocolOperation type, which is supposed to contain extra info(like da blob) which is not required for the rollup protocol along with the data that is required(like da commitment, deposit info, etc).
  2. Add a mechanism in filter_protocol_op_tx_refs wherein a function of type (&RawProtocolOperation) -> Result<()> can be passed such that prover can pass a no-op while full node can pass logic to store extra info to database if necessary.
  3. Adds unit test that tests multiple protocol ops(checkpoint and deposit in particular) can be parsed from a single transaction. Previously, only one operation could be parsed from a transaction.

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
  • New or updated tests
  • Dependency Update

Notes to Reviewers

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

STR-935

@bewakes bewakes force-pushed the STR-807-inscription-changes branch from da8be4c to e78e71d Compare January 20, 2025 10:12
Copy link
Contributor

github-actions bot commented Jan 20, 2025

Commit: a8d4e6e

SP1 Performance Test Results

program cycles success
BTC_BLOCKSPACE 30,357,513
EL_BLOCK 98,789
CL_BLOCK 57,214
L1_BATCH 30,387,795
L2_BATCH 5,473
CHECKPOINT 15,895

@bewakes bewakes force-pushed the STR-807-inscription-changes branch 4 times, most recently from 0a66e86 to d8f04ee Compare January 21, 2025 11:26
@bewakes bewakes force-pushed the STR-402-rework-protocol-op-types branch 2 times, most recently from 6c885d6 to 505735d Compare January 21, 2025 12:18
@bewakes bewakes marked this pull request as ready for review January 21, 2025 13:03
@bewakes bewakes requested review from a team as code owners January 21, 2025 13:03
Copy link

codecov bot commented Jan 21, 2025

Codecov Report

Attention: Patch coverage is 74.72527% with 46 lines in your changes missing coverage. Please review.

Project coverage is 56.28%. Comparing base (3eb992c) to head (fcf9d7c).

Files with missing lines Patch % Lines
crates/consensus-logic/src/l1_handler.rs 0.00% 9 Missing ⚠️
crates/l1tx/src/filter/mod.rs 92.07% 8 Missing ⚠️
crates/consensus-logic/src/duty/block_assembly.rs 0.00% 6 Missing ⚠️
crates/l1tx/src/messages.rs 40.00% 6 Missing ⚠️
crates/l1tx/src/filter/visitor.rs 64.28% 5 Missing ⚠️
crates/btcio/src/reader/ops_visitor.rs 0.00% 4 Missing ⚠️
crates/btcio/src/reader/query.rs 0.00% 4 Missing ⚠️
crates/state/src/l1/utils.rs 0.00% 2 Missing ⚠️
bin/strata-client/src/extractor.rs 94.73% 1 Missing ⚠️
crates/proof-impl/btc-blockspace/src/filter.rs 80.00% 1 Missing ⚠️
@@                       Coverage Diff                       @@
##           STR-807-inscription-changes     #618      +/-   ##
===============================================================
+ Coverage                        56.15%   56.28%   +0.12%     
===============================================================
  Files                              316      318       +2     
  Lines                            32852    32929      +77     
===============================================================
+ Hits                             18449    18535      +86     
+ Misses                           14403    14394       -9     
Files with missing lines Coverage Δ
crates/chaintsn/src/transition.rs 82.86% <100.00%> (ø)
crates/l1tx/src/filter/types.rs 95.65% <ø> (ø)
crates/rocksdb-store/src/l1/db.rs 97.29% <100.00%> (ø)
crates/state/src/l1/tx.rs 64.70% <100.00%> (-2.95%) ⬇️
crates/state/src/state_op.rs 43.97% <100.00%> (ø)
crates/state/src/tx.rs 0.00% <ø> (ø)
bin/strata-client/src/extractor.rs 95.02% <94.73%> (+0.45%) ⬆️
crates/proof-impl/btc-blockspace/src/filter.rs 53.84% <80.00%> (+3.84%) ⬆️
crates/state/src/l1/utils.rs 58.33% <0.00%> (ø)
crates/btcio/src/reader/ops_visitor.rs 0.00% <0.00%> (ø)
... and 6 more

... and 3 files with indirect coverage changes

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.

Need to rework the data structures a little bit to make them more accurately reflect the design we have now.

Also, see the visitor-oriented approach. The goal with that was to decouple the "figuring out what to do with protocol ops we get" from the "actually finding the protocol ops" parts so that handling can be different depending on if it's in the proof or in the reader.

Comment on lines 18 to 25
pub fn filter_protocol_op_tx_refs<F>(
block: &Block,
params: &RollupParams,
filter_config: &TxFilterConfig,
) -> Vec<ProtocolOpTxRef> {
process_raw: &mut F,
) -> Vec<ProtocolOpTxRef>
where
F: FnMut(&RawProtocolOperation) -> anyhow::Result<()>,
Copy link
Contributor

Choose a reason for hiding this comment

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

You can write this with &mut impl FnMut(...) -> ...

Comment on lines 23 to 24
/// Similar to [`ProtocolOperation`] except that this also contains blob data which is not relevant
/// to chain.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see DA blobs here.

Also it is relevant, we need to see the blob commitments.

I'm a bit confused about what the purpose of this type is, being distinct from the other one.

Copy link
Contributor Author

@bewakes bewakes Jan 22, 2025

Choose a reason for hiding this comment

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

Also it is relevant, we need to see the blob commitments.

Yes, the commitments, but not the actual data/blob which is what I meant in the docstring.

Copy link
Contributor Author

@bewakes bewakes Jan 22, 2025

Choose a reason for hiding this comment

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

'm a bit confused about what the purpose of this type is, being distinct from the other one.

So the idea here is that RawProtocolOp would contain a variant Da(Vec<u8>) whereas ProtocolOp would have the counterpart DaCommitment(Buf32). The other variants would be the same. Those(Da/DaCommithemt) are not here right now because we don't actually have DA at the moment.

Copy link
Contributor

@delbonis delbonis Jan 22, 2025

Choose a reason for hiding this comment

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

Just do the visitor thing. The approach with the handler function is just an roundabout and inelegant way of doing the same general idea. Do not copy out the full contents of DA into a type if it's not necessary. That's what the visitor based approach (that I guided in the original PR) enables.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PTAL

crates/state/src/state_op.rs Outdated Show resolved Hide resolved
crates/l1tx/src/messages.rs Outdated Show resolved Hide resolved
@bewakes bewakes mentioned this pull request Jan 22, 2025
13 tasks
@bewakes bewakes force-pushed the STR-807-inscription-changes branch from d8f04ee to 3eb992c Compare January 23, 2025 10:01
@bewakes bewakes requested a review from a team as a code owner January 23, 2025 10:01
@bewakes bewakes force-pushed the STR-402-rework-protocol-op-types branch from 9991efb to 501dbc9 Compare January 23, 2025 10:10
@bewakes bewakes requested a review from delbonis January 23, 2025 10:28
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.

(Discussed in core sync, leaving review here to continue work.)

}

// Do stuffs with DA.
fn visit_da(&self, d: &[u8]) -> ProtocolOperation {
Copy link
Contributor

Choose a reason for hiding this comment

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

chunks: impl Iterator<Item = &[u8]>

Comment on lines +7 to +24
pub trait OpsVisitor {
// Do stuffs with `SignedBatchCheckpoint`.
fn visit_checkpoint(&self, chkpt: SignedBatchCheckpoint) -> ProtocolOperation {
ProtocolOperation::Checkpoint(chkpt)
}

// Do stuffs with `DepositInfo`.
fn visit_deposit(&self, d: DepositInfo) -> ProtocolOperation {
ProtocolOperation::Deposit(d)
}

// Do stuffs with `DepositRequest`.
fn visit_deposit_request(&self, d: DepositRequestInfo) -> ProtocolOperation {
ProtocolOperation::DepositRequest(d)
}

// Do stuffs with DA.
fn visit_da(&self, d: &[u8]) -> ProtocolOperation {
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs to take &mut self.

@bewakes bewakes force-pushed the STR-807-inscription-changes branch from 3eb992c to d7dc0a9 Compare January 24, 2025 05:53
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.

2 participants