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

Add ExecutingMessageValidator trait #129

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sergerad
Copy link
Contributor

Closes #98

WIP

Copy link
Member

@emhane emhane left a comment

Choose a reason for hiding this comment

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

off to a good start

@sergerad sergerad force-pushed the sergerad/executing-message-validator branch from 42518b6 to f79be89 Compare January 24, 2025 02:12
// TODO: should we `impl From<Log> for ExecutingMessage`?
// There is `impl From<Log> for MessagePayload` but I'm unsure
// about the relationship between `MessagePayload` and `ExecutingMessage`
ExecutingMessage::abi_decode(&log.data.data, true)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@emhane Do you have any advice around the log decoding? The comment above this line summarizes my question(s).

If the approach here is in fact correct (ExecutingMessage::abi_decode(&log.data.data, true)), then should I add some logic that checks topics before attempting to decode? So as to filter out irrelevant logs rather than error out. E.G. similar idea to pub const CONFIG_UPDATE_TOPIC: B256.

TY!

Copy link
Member

Choose a reason for hiding this comment

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

you can find the logic to extract the executing messages here
https://github.com/op-rs/kona/blob/a59f643d0627320efff49f40f4803741ae9194f1/crates/interop/src/message.rs#L102-L114
not sure what the magic number 2 should be called as a constant instead @clabby ?

you're totally right that we don't want to return error, instead we just want to filter that log out if it doesn't contain an executing message

Comment on lines 25 to 27
fn parse_messages(
logs: &[Log],
) -> Result<Vec<ExecutingMessage>, ExecutingMessageValidatorError> {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fn parse_messages(
logs: &[Log],
) -> Result<Vec<ExecutingMessage>, ExecutingMessageValidatorError> {
fn filter_executing_msgs(
logs: &[Log],
) -> Result<impl IntoIterator<Item = ExecutingMessage>, ExecutingMessageValidatorError> {

let the caller collect better..maybe for some reason the caller wants to bail early, if we don't know, better leave it open by returning iterator and letting caller collect into vec

// TODO: should we `impl From<Log> for ExecutingMessage`?
// There is `impl From<Log> for MessagePayload` but I'm unsure
// about the relationship between `MessagePayload` and `ExecutingMessage`
ExecutingMessage::abi_decode(&log.data.data, true)
Copy link
Member

Choose a reason for hiding this comment

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

you can find the logic to extract the executing messages here
https://github.com/op-rs/kona/blob/a59f643d0627320efff49f40f4803741ae9194f1/crates/interop/src/message.rs#L102-L114
not sure what the magic number 2 should be called as a constant instead @clabby ?

you're totally right that we don't want to return error, instead we just want to filter that log out if it doesn't contain an executing message

@sergerad sergerad force-pushed the sergerad/executing-message-validator branch from f79be89 to deb0b94 Compare January 25, 2025 00:41
use alloy_sol_types::SolEvent;
use maili_interop::ExecutingMessage as InteropMessage;
use maili_interop::CROSS_L2_INBOX_ADDRESS;
use maili_protocol::ExecutingMessage as ProtocolMessage;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@emhane I have the two ExecutingMessage types here just for the sake of compilation atm.

The snippet you shared for parsing logs for ExecutingMessage relies on the interop crate. But the SupervisorApiClient uses the struct from protocol crate.

WDYT is the correct path here? E.G. I could use the protocol crate version and try to use ExecutingMessage::abi_decode instead. Or I could update the SupervisorApiClient to use the interop crate ExecutingMessage.

There are also some misc TODOs if you have time to weigh in on would be appreciated.

TY!

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.

[Feature] Define ExecutingMessageValidator
2 participants