Skip to content

feat: add trace offer for a series of content keys#1830

Merged
KolbyML merged 2 commits into
ethereum:masterfrom
KolbyML:send-trace-offer-with-multiple-items
May 15, 2025
Merged

feat: add trace offer for a series of content keys#1830
KolbyML merged 2 commits into
ethereum:masterfrom
KolbyML:send-trace-offer-with-multiple-items

Conversation

@KolbyML
Copy link
Copy Markdown
Member

@KolbyML KolbyML commented May 14, 2025

What was wrong?

send_offer_trace only accepts 1 key-value pair. In most cases that is fine, but for we want to send multiple key-value pairs in the Ephemeral History Bridge, so this doesn't work.

How was it fixed?

I am open to suggestions. I think it is easier/cleaner to expose an api which allows for the 1 key-value pair case and the multiple key-value case as they are pretty distinct.

@KolbyML KolbyML requested a review from morph-dev May 14, 2025 20:58
@KolbyML KolbyML self-assigned this May 14, 2025
Copy link
Copy Markdown
Collaborator

@morph-dev morph-dev left a comment

Choose a reason for hiding this comment

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

Looks mostly ok

🚢

}

/// Send Offer request with trace, without storing the content into db, with multiple items
pub async fn send_offer_trace_with_multiple_items(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There is some duplicated logic between this and function above it (send_offer_trace).
Can't we make send_offer_trace simpler, something like this:

pub async fn send_offer_trace(...) -> Result<OfferTrace, OverlayRequestError> {
    let content_items = vec![content_key, content_value];
    match self.send_offer_trace_with_multiple_items(enr, content_items).await? {
        OfferTraceMultipleItems::Success(accept_code_list) => {
            ...
        }
        OfferTraceMultipleItems::Failed => Ok(OfferTrace::Failed),
    }
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good idea!

content_keys.len()
);
if let Err(err) = tx.send(OfferTraceMultipleItems::Success(content_keys)) {
warn!(%err, "Unable to send OfferTrace Success result");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If I'm not mistaken, tx.send would fail only if channel is closed, but we wouldn't know why it's closed.

And since all error messages are the same (except Success / Failed part), it would be hard to know in which case this happens.

I think it's probably not so important to even log these messages (how it was before), but if we already want to do it, I would describe them a bit better (e.g. they would include something that indicates which line actually printed the message). If you want, I can make suggestions for that.

Either way, no big deal. Up to you.

Comment on lines +437 to +441
if let Err(err) = tx.send(OfferTraceMultipleItems::Success(content_keys)) {
warn!(%err, "Unable to send OfferTrace Success result");
}
let _ = tx.send(OfferTrace::Success(content_keys[0]));
} else {
let _ = tx.send(OfferTrace::Failed);
} else if let Err(err) = tx.send(OfferTraceMultipleItems::Failed) {
warn!(%err, "Unable to send OfferTrace Failed result");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: I would do this slightly differently:

let result = if result {
    OfferTraceMultipleItems::Success(content_keys)
} else {
    OfferTraceMultipleItems::Failed
};
if let Err(err) = tx.send(result) {
    warn!(%err, "Unable to send OfferTrace result");
}

@KolbyML KolbyML merged commit 5dca37d into ethereum:master May 15, 2025
16 checks passed
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