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

[Followup] Trait for relationships between receipts, logs, and log contents #623

Open
prestwich opened this issue Apr 24, 2024 · 2 comments
Labels
debt Tech debt which needs to be addressed enhancement New feature or request

Comments

@prestwich
Copy link
Member

prestwich commented Apr 24, 2024

We need trait bounds for specifying when the contents of a receipt log vector can be interpreted as logs. I.e. a trait-based definition for what a log is, including encoded, decoded, rpc, consensus, etc.

This means that they contain a consensus::Log object (either consensus Log or RPC Log containing an inner consensus log) and that the data type consensus::Log<T> can be infallibly converted into LogData

          it's a bit more complicated and we will need more work here. Because `Log` is actually `Log<T = LogData>` we want to be able to implement generically across a wide variety of types, and may need to introduce a `trait Log` in order to do it

          For now, this is an improvement over the existing state of things so we might as well

Originally posted by @prestwich in #617 (comment)

@prestwich prestwich added enhancement New feature or request debt Tech debt which needs to be addressed labels Apr 24, 2024
@prestwich
Copy link
Member Author

See also:
#512 (comment)

@prestwich
Copy link
Member Author

How i'm currently thinking about this:

  • some types (like SolEvent) can be infallibly converted into LogData

    • this is currently captured as a messy for<'a> bound
    • should probably be an IntoLogData trait?
  • Log objects contain either LogData or some type that can be converted into it Log<T: IntoLogData>

  • some types contain log vectors trait HasLogs<T: IntoLogData>: AsRef<Log<T>> { }

    • This is partially captured by trait TxReceipt in alloy-consensus
    • ReceiptEnvelope AND RpcReceipt AND consensus::Receipt should implement HasLogs<T>
  • N::ReceiptEnvelope and N::ReceiptResponse types contain log vectors

    • new bound on those assoc types
  • N::ReceiptResponse should always contain a ReceiptEnvelope

    • new bound no that assoc type AsRef<Self::ReceiptEnvelope>
  • All <N as Network>::ReceiptResponse types contain a ReceiptEnvelope

    • new bound ReceiptResponse: AsRef<ReceiptEnvelope> + TxReceipt
    • as a result, we can also bound + TxReceipt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debt Tech debt which needs to be addressed enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant