diff --git a/crates/rundler/src/op_pool/mempool/mod.rs b/crates/rundler/src/op_pool/mempool/mod.rs index 0d5e94960..8be005fb3 100644 --- a/crates/rundler/src/op_pool/mempool/mod.rs +++ b/crates/rundler/src/op_pool/mempool/mod.rs @@ -15,7 +15,7 @@ use mockall::automock; pub use reputation::{ HourlyMovingAverageReputation, Reputation, ReputationParams, ReputationStatus, }; -use rundler_types::{Entity, EntityType, UserOperation}; +use rundler_types::{Entity, EntityType, UserOperation, USER_OPERATION_PACKED_LEN}; use strum::IntoEnumIterator; use tonic::async_trait; @@ -164,7 +164,7 @@ impl PoolOperation { } pub fn size(&self) -> usize { - self.uo.pack().len() + USER_OPERATION_PACKED_LEN } fn entity_address(&self, entity: EntityType) -> Option
{ diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs index 52867fa24..268235a4e 100644 --- a/crates/types/src/lib.rs +++ b/crates/types/src/lib.rs @@ -8,7 +8,7 @@ //! Rundler common types mod user_operation; -pub use user_operation::UserOperationId; +pub use user_operation::{UserOperationId, USER_OPERATION_PACKED_LEN}; /// Generated contracts module #[allow(non_snake_case)] diff --git a/crates/types/src/user_operation.rs b/crates/types/src/user_operation.rs index 8189f58d2..92d0313c5 100644 --- a/crates/types/src/user_operation.rs +++ b/crates/types/src/user_operation.rs @@ -10,6 +10,9 @@ use crate::{ UserOperation, }; +/// size of a packed user operation in bytes +pub const USER_OPERATION_PACKED_LEN: usize = 320; + /// Unique identifier for a user operation from a given sender #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] pub struct UserOperationId { @@ -229,4 +232,10 @@ mod tests { .unwrap() ); } + + #[test] + fn test_pack_len() { + let user_operation = UserOperation::default(); + assert_eq!(user_operation.pack().len(), USER_OPERATION_PACKED_LEN); + } }