-
Notifications
You must be signed in to change notification settings - Fork 5
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-881 inscription changes #590
base: main
Are you sure you want to change the base?
Conversation
b5e3480
to
286799a
Compare
286799a
to
9e770e7
Compare
Commit: 107387d SP1 Performance Test Results
|
54e228e
to
7584ba8
Compare
9e770e7
to
16a2890
Compare
07fc70b
to
cc85da7
Compare
16a2890
to
0528eff
Compare
cc85da7
to
2eda45d
Compare
0528eff
to
727ef1a
Compare
1fbb9a5
to
037c18f
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.
This is a good start but what I would like to see is a new RPC that lets us test this new functionality properly and more explicit functional tests for it. I don't think enough is sufficiently covered.
This also doesn't get to replicating the visitor-based stuff in the old PR, but that wasn't quite ready yet and we're not going to be in a position with tn1 to be able to take advantage of it yet, so I'm not sure if it's worth trying to work on here. What do you think?
@@ -410,7 +410,7 @@ fn perform_duty<D: Database, E: ExecEngineCtl>( | |||
Ok(()) | |||
} | |||
Duty::CommitBatch(data) => { | |||
info!(data = ?data, "commit batch"); | |||
info!(data = ?data, "commit batch duty"); |
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.
?data
But really we should not print the contents here, that's unnecessarily verbose, especially for an info!
log.
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.
True. Just logged the idx.
crates/l1tx/src/envelope/builder.rs
Outdated
trace!(batchdata_size = %payload.data().len(), "Inserting batch data"); | ||
for chunk in payload.data().chunks(520) { | ||
trace!(size=%chunk.len(), "inserting chunk"); |
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.
This is way into the internals. We just have extensive-enough unit tests it so that we never have to worry about if it's correct or not.
Logs are most useful to have closer to the boundaries of components or for high level components doing significant operations the user might want to know about, where we might have to worry about unexpected interactions we want to go look at later.
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.
Agreed. Removed the trace here.
crates/l1tx/src/envelope/parser.rs
Outdated
} | ||
|
||
fn parse_payload_type(bytes: &[u8], params: &RollupParams) -> Option<L1PayloadType> { | ||
let str = from_utf8(bytes).ok()?; |
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.
Instead of trying to parse the bytes as UTF-8 first, interpret the strings we're comparing against as bytes and compare that like tag_bytes == params.checkpoint_tag.as_bytes()
.
Also, don't like var names that shadow type names, would have called this tag_str
to also be more explicit.
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.
That's a good point. Changed to checking bytes. Conversion to string was really unnecessary.
I see what you are trying to say here. What we don't have exactly is testing of creation of envelopes and accepting them by the client. However, the unit tests do cover parsing multiple envelopes and getting
Yes, Initially I was thinking I would do it here, but since this is getting bigger and another ticket also touches on this, it might be better to do it there(or split that one also if necessary). enum RawProtocolOp {
Da(vec<u8>), // This has all of the DA data
Checkpoint(CheckpointData),
Deposit(..),
DepositInfo(..),
}
// Actual operations, which prover cares and is in the chain
enum ProtocolOp {
Da(vec<u8>), // This only has commitment, others will probably stay the same
Checkpoint(CheckpointData),
Deposit(..),
DepositInfo(..),
}
// This takes a fn impl so any extra logic like storing raw data to db can be done
// there and pass a no op otherwise.
fn process_raw_op(
d: RawProtocolOp,
f: impl FnOnce(RawProtocolOp) -> Result<()>
) -> Result<L1ProtocolOp> {
let txop = to_tx_op(&d);
f(d)?;
Ok(txop)
} Which will be used in prover and full node as: fn extract_tx_ops_prover(tx: Transasction, params: Params, ..) -> Vec<L1ProtocolOp> {
let raw_ops = extract_raw_protocol_ops(tx, params);
raw_ops.map(|r| process_raw_op(r, |_| Ok(()))).collect()
}
fn extract_tx_ops_client(tx: Transasction, params: Params, db: Manager) -> Vec<L1ProtocolOp> {
let raw_ops = extract_raw_protocol_ops(tx, params);
raw_ops.map(|r| process_raw_op(r, |d| db.insert(d)).collect()
} |
037c18f
to
869ffec
Compare
869ffec
to
da8be4c
Compare
da8be4c
to
e78e71d
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.
minor nits and comments
@@ -52,7 +52,7 @@ pub enum EnvelopeError { | |||
// dependencies on `tx-parser`, we include {btcio, feature="strata_test_utils"} , so cyclic | |||
// dependency doesn't happen | |||
pub async fn build_envelope_txs<W: WriterRpc>( | |||
payload: &L1Payload, | |||
payloads: &[L1Payload], |
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.
One thing that we can do is to make this accept both a single but also multiple LaPayload
s:
pub async fn build_envelope_txs<'a, I: IntoIterator<Item = &'a L1Payload>, W: WriterRpc>(
payload: I,
//...
/// Periodically bundles unbundled intents into payload entries. | ||
pub(crate) async fn bundler_task(ops: Arc<EnvelopeDataOps>) -> anyhow::Result<()> { | ||
let mut last_idx = 0; | ||
loop { |
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.
Ugh, this loop
does not have a break
.
I know that it is supposed to loop forever until the process is terminated, but still "code smells" for me.
/// [`PayloadEntry`] | ||
pub trait SequencerDatabase { | ||
type L1PayloadDB: L1PayloadDatabase; | ||
/// A trait encapsulating provider and store traits to create/update [`BundledPayloadEntry`] in the |
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.
/// A trait encapsulating provider and store traits to create/update [`BundledPayloadEntry`] in the | |
/// Encapsulates provider and store traits to create/update [`BundledPayloadEntry`] in the |
It is a docstring to a "trait" hence it is implicit.
} | ||
_ => Err(EnvelopeParseError::InvalidNameTag), | ||
}?; | ||
fn parse_l1_payload( |
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.
This function and the parse_payload_type
below are awesome candidates for fuzzing.
Even if you just run locally (and don't need to setup CI, infra etc) it can pay huge dividends. Caught a bunch of simple and trivial bugs in as least as 5 min running in bitcoin-bosd
thanks to @AaronFeickert (no action needed).
// completely valid control block | ||
fn create_envelope_tx(rollup_name: String) -> Transaction { | ||
// completely valid control block. Includes `n_envelopes` envelopes in the tapscript. | ||
fn create_checkpoint_envelope_tx(params: Arc<Params>, n_envelopes: u32) -> Transaction { |
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.
Since this is a library crate, I have to ask if it is really necessary to Arc<Params>
here instead of &Params
and then Arc
'ing + derefing in any binary crate that consumes it?
This PR primarily introduces the following changes:
BundledPayloadEntry
and stores in db, which is ultimately published to bitcoin. Currently, it just does 1-1 mapping like it was before, but the bundling logic can be advanced in future.Type of Change
Notes to Reviewers
Checklist
Related Issues