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

STR-726: Rework on Inscription Structure #518

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

voidash
Copy link
Contributor

@voidash voidash commented Dec 4, 2024

Description

Following are the main changes made for Inscription Transaction

  • Multiple Envelopes in a single script is supported
  • Envelope format
OP_FALSE
OP_IF
<Tag> (Either Checkpoint or DA)
Data [0..520]
....
OP_ENDIF 
(OP_FALSE
OP_IF // No rollup name required for further envelopes
<Tag> (Either Checkpoint or DA)
Data [0..520]
....
OP_ENDIF
)*
  • Pivot from inscription type naming system

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

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-726

@voidash voidash requested review from a team as code owners December 4, 2024 06:10
Copy link

codecov bot commented Dec 4, 2024

Codecov Report

Attention: Patch coverage is 61.61746% with 299 lines in your changes missing coverage. Please review.

Project coverage is 57.17%. Comparing base (506fd5c) to head (d8d9e61).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/btcio/src/writer/task.rs 35.25% 90 Missing ⚠️
crates/state/src/da_blob.rs 25.00% 24 Missing ⚠️
crates/rpc/types/src/types.rs 0.00% 18 Missing ⚠️
bin/strata-client/src/rpc_server.rs 0.00% 17 Missing ⚠️
crates/consensus-logic/src/duty/worker.rs 0.00% 17 Missing ⚠️
crates/btcio/src/writer/config.rs 0.00% 16 Missing ⚠️
bin/datatool/src/util.rs 0.00% 15 Missing ⚠️
crates/btcio/transaction/src/utils.rs 13.33% 13 Missing ⚠️
crates/btcio/transaction/src/visitor.rs 81.69% 13 Missing ⚠️
crates/rpc/btcio-types/src/error.rs 0.00% 13 Missing ⚠️
... and 16 more
@@            Coverage Diff             @@
##             main     #518      +/-   ##
==========================================
- Coverage   57.33%   57.17%   -0.16%     
==========================================
  Files         309      310       +1     
  Lines       31510    31718     +208     
==========================================
+ Hits        18067    18136      +69     
- Misses      13443    13582     +139     
Files with missing lines Coverage Δ
bin/bridge-client/src/modes/operator/bootstrap.rs 0.00% <ø> (ø)
...n/bridge-client/src/modes/operator/task_manager.rs 0.00% <ø> (ø)
bin/datatool/src/args.rs 0.00% <ø> (ø)
bin/prover-client/src/main.rs 0.00% <ø> (ø)
bin/prover-client/src/operators/btc.rs 0.00% <ø> (ø)
bin/prover-client/src/operators/l1_batch.rs 0.00% <ø> (ø)
bin/prover-client/src/operators/operator.rs 0.00% <ø> (ø)
bin/strata-client/src/l1_reader.rs 0.00% <ø> (ø)
crates/btcio/src/broadcaster/handle.rs 34.28% <ø> (ø)
crates/btcio/src/broadcaster/task.rs 87.69% <ø> (ø)
... and 49 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.

Another more general issue here that's being continued which we should rectify is that we're being very loose with our terminology. I've tried to be consistent with the code that's written in the review comments here to make it easy to understand, but we should rename several of the types to better reflect this.

See @john-light 's comment on jira ticket: https://alpenlabs.atlassian.net/browse/STR-649?focusedCommentId=10918

The term "blob" in the context of rollups generally refers specifically to DA. We're using the term this way in the chainstate types, but in this inscription code we're being loose with it and also using it to refer to what we put checkpoints into. I suggest we refer to the term "payload" to refer specifically to the data that gets put inside an envelope. There was some fields named to this effect before but we should be more explicit about it.

Secondly, since we're trying to optimize more for efficiency rather than following the inscription format, we should move away from the term "inscription" internally. It's following the same envelope format, but the internal structure is completely different, for good reason. So I suggest that we use the term "bundle" (or "data bundle" or "envelope bundle", whichever is more appropriate in a context) here instead. A bundle explicitly contains one or more envelopes with a tag and a payload. The envelopes within a bundle are independent and could contain messages from multiple protocols, if we wanted to.

If we were adding support for Celestia DA, we'd publish the payloads as separate messages and reason about them separately. As we're doing internally with the BlobId types.

So with this we'd rename types like this:

  • InscriptionBlob -> BundlePayload
  • BlobType -> PayloadTypeTag
  • BlobCommitment -> PayloadCommitment
  • BlobSpec -> PayloadSpec
  • also maybe introducing a new type BundleSpec to describe multiple envelopes in a single tx
  • BlobDest -> DataBundleDest
  • BlobIntent -> PayloadIntent
  • possibly some others that I'm missing

And of course (unfortunately) we have to update the comments on these types to refer to these changes.

Make sure to read all the points in the ticket. There's some requirements around code organization to help keep things clean that need to be addressed.

crates/state/src/tx.rs Outdated Show resolved Hide resolved
crates/state/src/da_blob.rs Outdated Show resolved Hide resolved
crates/state/src/da_blob.rs Show resolved Hide resolved
crates/state/src/tx.rs Outdated Show resolved Hide resolved
crates/db/src/types.rs Outdated Show resolved Hide resolved
crates/tx-parser/src/inscription.rs Outdated Show resolved Hide resolved
crates/btcio/src/writer/builder.rs Outdated Show resolved Hide resolved
crates/btcio/src/writer/builder.rs Outdated Show resolved Hide resolved
crates/state/src/tx.rs Outdated Show resolved Hide resolved
crates/tx-parser/src/filter.rs Outdated Show resolved Hide resolved
@voidash voidash requested review from a team as code owners December 11, 2024 11:52
@john-light john-light changed the title STR-649: Rework on Inscription Structure STR-726: Rework on Inscription Structure Dec 11, 2024
storopoli
storopoli previously approved these changes Dec 11, 2024
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.

ACK 59c60e6

Just saw the parts that I am a CODEOWNER: CI and BTC.

crates/btcio/src/writer/test_utils.rs Show resolved Hide resolved
@voidash voidash requested review from a team as code owners December 16, 2024 07:02
@voidash voidash force-pushed the STR-649-FIX-INSCRIPTION-STRUCTURE branch from 51a71ea to df4c511 Compare December 16, 2024 08:56
@voidash voidash requested a review from a team as a code owner December 16, 2024 08:56
@voidash voidash force-pushed the STR-649-FIX-INSCRIPTION-STRUCTURE branch from df4c511 to f90a764 Compare December 16, 2024 09:49
bin/datatool/src/util.rs Outdated Show resolved Hide resolved
crates/db/src/traits.rs Outdated Show resolved Hide resolved
crates/rocksdb-store/src/sequencer/db.rs Outdated Show resolved Hide resolved
crates/rpc/types/src/types.rs Outdated Show resolved Hide resolved
crates/db/src/types.rs Outdated Show resolved Hide resolved
crates/db/src/types.rs Outdated Show resolved Hide resolved
crates/storage/src/ops/envelope.rs Outdated Show resolved Hide resolved
@voidash voidash requested a review from delbonis December 18, 2024 01:33
storopoli
storopoli previously approved these changes Dec 18, 2024
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.

ACK 12d1ad7
The btcio/traits -> btcio-types refactor is nice.

This is just from the CI, bin, and btc CODEOWNERS

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.

The type hierarchy for the bundle/envelope/payload types still feels a bit strange. Not sure the best way to fix that without just rewriting all the structs.

I also noticed there's the waiting_da_blobs and related state fields. Don't change these now since they're far away from the writer logic. I'm working on a PR touching related code and these will probably be refactored then.

crates/rpc/api/src/lib.rs Outdated Show resolved Hide resolved
crates/rpc/btcio-types/src/error.rs Outdated Show resolved Hide resolved
crates/state/src/da_blob.rs Outdated Show resolved Hide resolved
crates/state/src/da_blob.rs Outdated Show resolved Hide resolved
bin/datatool/src/args.rs Outdated Show resolved Hide resolved
@voidash voidash force-pushed the STR-649-FIX-INSCRIPTION-STRUCTURE branch from 34a37c9 to 04f59bf Compare December 22, 2024 10:36
btcio,tx-parser: change parsing logic for inscription, add new protocol operation

tx-parser,rpc: add two submit blob rpc endpoint variant, fix envelope entering bug

tx-parser: taplo format

state,tx-parser: add comments

remove inscription from codebase and make it envelope, resolve comments

EnvelopeDB to CommitRevealDb

create envelope-tx, split btcio rpc types to different crate

store whole Vec<u8> instead of BundledCommitment on DA ProtocolOperation

formatting

remove descriptor.rs

rename tx-parser to tx-filter and envelope-tx to reveal-tx

datatool: better description for newly added cmds

add _dd to codespellrc, remove smart-fee arg from datatool, use writerDB instead of sequencerDB

add DAFilterMode, change da submit rpc

fix formatting issues

resolve comments
@voidash voidash force-pushed the STR-649-FIX-INSCRIPTION-STRUCTURE branch from 04f59bf to 98e875e Compare December 22, 2024 10:53
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 overall, the use of visitor pattern seems a bit complicated though.

Need to add unit tests for parsing multiple protocol ops from a single transaction.

crates/btcio/transaction/filter/src/lib.rs Outdated Show resolved Hide resolved
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.

What we discussed in DMs was a sensible approach. This is very different. What was the reasoning for doing this? There's a few issues with it. It duplicates the high level envelope parsing logic and making 2 passes for checkpoints and DA. If we were to add another type of payload (like a forced inclusion) this would mean another instance of it.

We always want to take and parse the full contents of checkpoint payloads, so using the visitor-based approach doesn't help us much, it just complicates the code. The goal of using the visitors for DA was to ideally avoid copies depending on the context.

crates/transaction/reveal/src/visitor.rs Outdated Show resolved Hide resolved
crates/transaction/reveal/src/visitor.rs Outdated Show resolved Hide resolved
crates/transaction/reveal/src/visitor.rs Outdated Show resolved Hide resolved
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.

5 participants