Skip to content

Commit

Permalink
add KethEvent to encode state (#189)
Browse files Browse the repository at this point in the history
Part of #139
  • Loading branch information
tcoratger authored Dec 3, 2024
1 parent 1c4d5d5 commit d5163f1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions crates/exex/src/model/event.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use super::primitives::KethPointer;
use serde::{Deserialize, Serialize};

/// Represents an Ethereum event in the Keth model.
///
/// Events are used in the Ethereum Virtual Machine (EVM) to log information during contract
/// execution. They are composed of `topics` and `data`, where:
/// - `topics`: A list of indexed fields that can be used for efficient filtering and querying.
/// - `data`: Additional unindexed information related to the event.
///
/// This struct provides a Keth-compatible representation of Ethereum events, where both `topics`
/// and `data` are stored as `KethPointer` to ensure compatibility with the Cairo VM's constraints.
#[derive(Debug, Eq, Ord, Hash, PartialEq, PartialOrd, Clone, Serialize, Deserialize)]
pub struct KethEvent {
/// The indexed topics associated with the event.
///
/// Topics allow filtering of events based on specific criteria. Each topic is typically a
/// 256-bit value represented as a [`KethPointer`] to ensure compatibility with Cairo VM
/// constraints.
///
/// In the Cairo VM, topics are an array of Felts.
pub topics: KethPointer,

/// The unindexed data associated with the event.
///
/// This field contains the raw data emitted by the event, which is not indexed but can
/// provide additional context about the event.
///
/// The data is stored as a [`KethPointer`] (an array of Felts in the Cairo VM).
pub data: KethPointer,
}
1 change: 1 addition & 0 deletions crates/exex/src/model/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod block;
pub mod event;
pub mod header;
pub mod payload;
pub mod primitives;
Expand Down

0 comments on commit d5163f1

Please sign in to comment.