-
Notifications
You must be signed in to change notification settings - Fork 107
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
Pass structured event log to ethereumInboundQueue.submit #1003
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1003 +/- ##
=======================================
Coverage 81.13% 81.14%
=======================================
Files 52 53 +1
Lines 2115 2132 +17
Branches 72 72
=======================================
+ Hits 1716 1730 +14
- Misses 384 387 +3
Partials 15 15
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
use sp_runtime::RuntimeDebug; | ||
use sp_std::vec::Vec; | ||
|
||
/// A trait for verifying inbound messages from Ethereum. | ||
pub trait Verifier { | ||
fn verify(message: &Message) -> Result<(), VerificationError>; | ||
fn verify(event: &Log, proof: &Proof) -> Result<(), VerificationError>; |
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.
Maybe not directly relevant to change in this PR, I would assume event
is not required for the verification.
With the proof
and header.receipts_root
we can generate the receipt
which internally already contains the event log.
let receipt = match Self::verify_receipt_inclusion(header.receipts_root, &message.proof) { |
snowbridge/parachain/primitives/ethereum/src/receipt.rs
Lines 10 to 15 in 6b59223
pub struct Receipt { | |
pub post_state_or_status: Vec<u8>, | |
pub cumulative_gas_used: u64, | |
pub bloom: Bloom, | |
pub logs: Vec<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.
Yeah, that's a good observation. I saw that as well while doing this PR.
However I think its easier to troubleshoot problems if the Log
is submitted as well. Otherwise if there are issues, we would have to decode the Proof
manually to extract the Log. Which brings us full circle to the problem this PR is solving - improving debuggability.
We were making life difficult for ourselves by passing the message data (event log) as raw bytes. Makes troubleshooting harder, and also increases complexity of on-chain unnecessarily, as it has to decode the bytes. This also brings with it a small security risk, if the decoding can be exploited somehow.
I have also updated the
register_token
smoketest to pretty-print the event log (thanks @yrong for initiating that).The only issue is that our codebase now has two
Log
types:snowbridge_core::inbound::Log
snowbridge_ethereum::log::Log
I didn't standardize on
snowbridge_ethereum::log::Log
, as that crate uses various ethereum dependencies that are kinda deprecated and unmaintained. Rust folks are now using this library for ethereum types: https://github.com/alloy-rs/core. Anyway, this olderLog
version is still used by the beacon light client.So I created
snowbridge_core::inbound::Log
, which is only used by the inbound-queue crate, and converted tosnowbridge_ethereum::log::Log
when needed.