Skip to content

Commit

Permalink
remove sov events (#1601)
Browse files Browse the repository at this point in the history
  • Loading branch information
eyusufatik authored Dec 12, 2024
1 parent 44bcd72 commit ce45b3a
Show file tree
Hide file tree
Showing 34 changed files with 99 additions and 389 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/citrea/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ citrea-evm = { path = "../../crates/evm", features = ["native"] }
citrea-primitives = { path = "../../crates/primitives", features = ["testing"] }
sov-mock-da = { path = "../../crates/sovereign-sdk/adapters/mock-da", default-features = false }
sov-prover-storage-manager = { path = "../../crates/sovereign-sdk/full-node/sov-prover-storage-manager", features = ["test-utils"] }
sov-rollup-interface = { path = "../../crates/sovereign-sdk/rollup-interface", features = ["fuzzing", "testing"] }
sov-rollup-interface = { path = "../../crates/sovereign-sdk/rollup-interface", features = ["testing"] }

alloy = { workspace = true, features = ["hyper", "consensus", "rpc-types-eth", "provider-http", "signers", "signer-local"] }
alloy-rlp = { workspace = true }
Expand Down
2 changes: 0 additions & 2 deletions crates/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ impl<C: sov_modules_api::Context> sov_modules_api::Module for Evm<C> {

type CallMessage = call::CallMessage;

type Event = ();

fn genesis(&self, config: &Self::Config, working_set: &mut WorkingSet<C::Storage>) {
self.init_module(config, working_set)
}
Expand Down
2 changes: 0 additions & 2 deletions crates/soft-confirmation-rule-enforcer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ impl<C: Context, Da: DaSpec> sov_modules_api::Module for SoftConfirmationRuleEnf

type CallMessage = CallMessage<C>;

type Event = ();

fn call(
&mut self,
message: Self::CallMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ impl SharedLedgerOps for LedgerDB {
Ok(())
}

/// Get the next slot, block, transaction, and event numbers
/// Get the next slot, block, transaction numbers
#[instrument(level = "trace", skip(self), ret)]
fn get_next_items_numbers(&self) -> ItemNumbers {
self.next_item_numbers.lock().unwrap().clone()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub trait SharedLedgerOps {
l2_height: BatchNumber,
) -> Result<()>;

/// Get the next slot, block, transaction, and event numbers
/// Get the next slot, block, transaction numbers
fn get_next_items_numbers(&self) -> ItemNumbers;

/// Gets all slots with numbers `range.start` to `range.end`. If `range.end` is outside
Expand Down
4 changes: 0 additions & 4 deletions crates/sovereign-sdk/full-node/db/sov-db/src/schema/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
//! - `TxNumber -> (TxHash,Tx)`
//! - `TxHash -> TxNumber`
//!
//! Event Tables:
//! - `(EventKey, TxNumber) -> EventNumber`
//! - `EventNumber -> (EventKey, EventValue)`
//!
//! JMT Tables:
//! - `KeyHash -> Key`
//! - `(Key, Version) -> JmtValue`
Expand Down
28 changes: 1 addition & 27 deletions crates/sovereign-sdk/full-node/db/sov-db/src/schema/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ use std::sync::Arc;

use borsh::{BorshDeserialize, BorshSerialize};
use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
use sov_rollup_interface::rpc::{
BatchProofOutputRpcResponse, BatchProofResponse, HexTx, LightClientProofOutputRpcResponse,
LightClientProofResponse, SoftConfirmationResponse, TxIdentifier, TxResponse,
VerifiedBatchProofResponse,
LightClientProofResponse, SoftConfirmationResponse, TxResponse, VerifiedBatchProofResponse,
};
use sov_rollup_interface::soft_confirmation::SignedSoftConfirmation;
use sov_rollup_interface::stf::EventKey;
use sov_rollup_interface::zk::{BatchProofInfo, CumulativeStateDiff, Proof};

/// A cheaply cloneable bytes abstraction for use within the trust boundary of the node
Expand Down Expand Up @@ -359,29 +356,6 @@ impl<R: DeserializeOwned> TryFrom<StoredTransaction> for TxResponse<R> {
}
}

/// An identifier that specifies a single event
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub enum EventIdentifier {
/// A unique identifier for an event consisting of a [`TxIdentifier`] and an offset into that transaction's event list
TxIdAndIndex((TxIdentifier, u64)),
/// A unique identifier for an event consisting of a [`TxIdentifier`] and an event key
TxIdAndKey((TxIdentifier, EventKey)),
/// The monotonically increasing number of the event, ordered by the DA layer For example, if the first tx
/// contains 7 events, tx 2 contains 11 events, and tx 3 contains 7 txs,
/// the last event in tx 3 would have number 25. The counter never resets.
Number(EventNumber),
}

/// An identifier for a group of related events
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub enum EventGroupIdentifier {
/// All of the events which occurred in a particular transaction
TxId(TxIdentifier),
/// All events which a particular key
/// (typically, these events will have been emitted by several different transactions)
Key(Vec<u8>),
}

macro_rules! u64_wrapper {
($name:ident) => {
/// A typed wrapper around u64 implementing `Encode` and `Decode`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn snapshot_lifecycle() {
manager.add_snapshot(snapshot_2.into());
}

// Snapshot 3: gets empty result, event value is in some previous snapshots
// Snapshot 3: gets empty result value is in some previous snapshots
let snapshot_3 = DbSnapshot::new(2, ReadOnlyLock::new(manager.clone()));
assert_eq!(None, snapshot_3.read::<S>(&key).unwrap());
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ pub mod module_a {

type CallMessage = ();

type Event = ();

fn call(
&mut self,
_message: Self::CallMessage,
Expand All @@ -39,7 +37,6 @@ pub mod module_a {

impl<C: Context> ModuleA<C> {
pub fn update(&mut self, key: &str, value: &str, working_set: &mut WorkingSet<C::Storage>) {
working_set.add_event("module A", "update");
self.state_1_a
.set(&key.to_owned(), &value.to_owned(), working_set);
self.state_2_a.set(&value.to_owned(), working_set)
Expand Down Expand Up @@ -71,8 +68,6 @@ pub mod module_b {

type CallMessage = ();

type Event = ();

fn call(
&mut self,
_message: Self::CallMessage,
Expand All @@ -86,7 +81,6 @@ pub mod module_b {

impl<C: Context> ModuleB<C> {
pub fn update(&mut self, key: &str, value: &str, working_set: &mut WorkingSet<C::Storage>) {
working_set.add_event("module B", "update");
self.state_1_b
.set(&key.to_owned(), &value.to_owned(), working_set);
self.mod_1_a.update("key_from_b", value, working_set);
Expand Down Expand Up @@ -118,8 +112,6 @@ pub(crate) mod module_c {

type CallMessage = ();

type Event = ();

fn call(
&mut self,
_message: Self::CallMessage,
Expand All @@ -138,7 +130,6 @@ pub(crate) mod module_c {
value: &str,
working_set: &mut WorkingSet<C::Storage>,
) {
working_set.add_event("module C", "execute");
self.mod_1_a.update(key, value, working_set);
self.mod_1_b.update(key, value, working_set);
self.mod_1_a.update(key, value, working_set);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use sov_modules_api::default_context::{DefaultContext, ZkDefaultContext};
use sov_modules_api::prelude::*;
use sov_modules_api::{Context, Event, ModulePrefix, StateMap, WorkingSet};
use sov_modules_api::{Context, ModulePrefix, StateMap, WorkingSet};
use sov_prover_storage_manager::new_orphan_storage;
use sov_state::{Storage, ZkStorage};

Expand All @@ -17,16 +17,6 @@ fn nested_module_call_test() {
execute_module_logic::<DefaultContext>(&mut working_set);
test_state_update::<DefaultContext>(&mut working_set);
}
assert_eq!(
working_set.events(),
&vec![
Event::new("module C", "execute"),
Event::new("module A", "update"),
Event::new("module B", "update"),
Event::new("module A", "update"),
Event::new("module A", "update"),
]
);

let (log, mut witness) = working_set.checkpoint().freeze();
prover_storage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ impl<C: Context> sov_modules_api::Module for Accounts<C> {

type CallMessage = ();

type Event = ();

fn genesis(&self, config: &Self::Config, working_set: &mut WorkingSet<C::Storage>) {
self.init_module(config, working_set)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ pub use sov_rollup_interface::services::da::SlotData;
pub use sov_rollup_interface::soft_confirmation::{
SignedSoftConfirmation, UnsignedSoftConfirmation, UnsignedSoftConfirmationV1,
};
pub use sov_rollup_interface::stf::{Event, StateDiff};
pub use sov_rollup_interface::stf::StateDiff;
pub use sov_rollup_interface::zk::{BatchProofCircuitOutput, Zkvm};
pub use sov_rollup_interface::{digest, BasicAddress, RollupAddress};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ pub use sov_modules_macros::MessageCodec;
/// type Context = C;
/// type Config = PhantomData<C>;
/// type CallMessage = ();
/// type Event = ();
///
/// fn call(
/// &mut self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ pub trait Module {
/// Module defined argument to the call method.
type CallMessage: Debug + BorshSerialize + BorshDeserialize;

/// Module defined event resulting from a call method.
type Event: Debug + BorshSerialize + BorshDeserialize;

/// Genesis is called when a rollup is deployed and can be used to set initial state values in the module.
/// Genesis functions can't return error, they must panic
fn genesis(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
//! Runtime state machine definitions.
use alloc::collections::BTreeMap;
use alloc::vec::Vec;
use core::{fmt, mem};

use sov_rollup_interface::stf::Event;

use self::archival_state::ArchivalOffchainWorkingSet;
use crate::archival_state::{ArchivalAccessoryWorkingSet, ArchivalJmtWorkingSet};
use crate::common::Prefix;
Expand Down Expand Up @@ -378,7 +375,6 @@ impl<S: Storage> StateCheckpoint<S> {
delta: RevertableWriter::new(self.delta, None),
offchain_delta: RevertableWriter::new(self.offchain_delta, None),
accessory_delta: RevertableWriter::new(self.accessory_delta, None),
events: Default::default(),
archival_working_set: None,
archival_accessory_working_set: None,
archival_offchain_working_set: None,
Expand Down Expand Up @@ -423,7 +419,6 @@ pub struct WorkingSet<S: Storage> {
delta: RevertableWriter<Delta<S>>,
accessory_delta: RevertableWriter<AccessoryDelta<S>>,
offchain_delta: RevertableWriter<OffchainDelta<S>>,
events: Vec<Event>,
archival_working_set: Option<ArchivalJmtWorkingSet<S>>,
archival_offchain_working_set: Option<ArchivalOffchainWorkingSet<S>>,
archival_accessory_working_set: Option<ArchivalAccessoryWorkingSet<S>>,
Expand Down Expand Up @@ -503,22 +498,6 @@ impl<S: Storage> WorkingSet<S> {
}
}

/// Adds an event to the working set.
pub fn add_event(&mut self, key: &str, value: &str) {
self.events.push(Event::new(key, value));
}

/// Extracts all events from this working set.
pub fn take_events(&mut self) -> Vec<Event> {
mem::take(&mut self.events)
}

/// Returns an immutable slice of all events that have been previously
/// written to this working set.
pub fn events(&self) -> &[Event] {
&self.events
}

/// Fetches given value and provides a proof of it presence/absence.
pub fn get_with_proof(&mut self, key: StorageKey) -> StorageProof<<S as Storage>::Proof>
where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ pub mod first_test_module {
type Context = C;
type Config = ();
type CallMessage = MyStruct;
type Event = ();

fn genesis(&self, _config: &Self::Config, _working_set: &mut WorkingSet<C::Storage>) {}

Expand Down Expand Up @@ -82,7 +81,6 @@ pub mod second_test_module {
type Context = Ctx;
type Config = ();
type CallMessage = MyEnum;
type Event = ();

fn genesis(&self, _config: &Self::Config, _working_set: &mut WorkingSet<Ctx::Storage>) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,10 @@ pub mod first_test_module {
}
}

#[derive(borsh::BorshDeserialize, borsh::BorshSerialize, Debug, PartialEq)]
pub enum Event {
FirstModuleEnum1(u64),
FirstModuleEnum2,
FirstModuleEnum3(Vec<u8>),
}

impl<C: Context> Module for FirstTestStruct<C> {
type Context = C;
type Config = ();
type CallMessage = u8;
type Event = Event;

fn genesis(&self, _config: &Self::Config, working_set: &mut WorkingSet<C::Storage>) {
self.state_in_first_struct.set(&1, working_set);
Expand Down Expand Up @@ -69,16 +61,10 @@ pub mod second_test_module {
}
}

#[derive(borsh::BorshDeserialize, borsh::BorshSerialize, Debug, PartialEq)]
pub enum Event {
SecondModuleEnum,
}

impl<Ctx: Context> Module for SecondTestStruct<Ctx> {
type Context = Ctx;
type Config = ();
type CallMessage = u8;
type Event = Event;

fn genesis(&self, _config: &Self::Config, working_set: &mut WorkingSet<Ctx::Storage>) {
self.state_in_second_struct.set(&2, working_set);
Expand Down Expand Up @@ -130,7 +116,6 @@ pub mod third_test_module {
type Context = Ctx;
type Config = ();
type CallMessage = OtherGeneric;
type Event = ();

fn genesis(&self, _config: &Self::Config, working_set: &mut WorkingSet<Ctx::Storage>) {
self.state_in_third_struct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ impl<C: Context> Module for TestStruct<C> {

type CallMessage = ();

type Event = ();

fn call(
&mut self,
_message: Self::CallMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ pub mod first_test_module {

type CallMessage = ();

type Event = ();

fn call(
&mut self,
_message: Self::CallMessage,
Expand Down Expand Up @@ -64,8 +62,6 @@ mod second_test_module {

type CallMessage = ();

type Event = ();

fn call(
&mut self,
_message: Self::CallMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ impl<C: Context> Module for QueryModule<C> {
type Context = C;
type Config = u8;
type CallMessage = u8;
type Event = ();

fn genesis(&self, config: &Self::Config, working_set: &mut WorkingSet<C::Storage>) {
self.data.set(config, working_set);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ pub mod my_module {
type Context = C;
type Config = D;
type CallMessage = D;
type Event = ();

fn genesis(&self, config: &Self::Config, working_set: &mut WorkingSet<C::Storage>) {
self.data.set(config, working_set);
Expand Down
Loading

0 comments on commit ce45b3a

Please sign in to comment.