From c00046b88d9f8cd308425215d467d3c4c3731ea9 Mon Sep 17 00:00:00 2001 From: itamar Date: Thu, 7 Nov 2024 13:56:51 -0500 Subject: [PATCH] add auction result --- .../src/generated/astria.bundle.v1alpha1.rs | 27 ++++ .../generated/astria.bundle.v1alpha1.serde.rs | 132 ++++++++++++++++++ .../astria/bundle/v1alpha1/bundle.proto | 16 +++ 3 files changed, 175 insertions(+) diff --git a/crates/astria-core/src/generated/astria.bundle.v1alpha1.rs b/crates/astria-core/src/generated/astria.bundle.v1alpha1.rs index 44265dd03d..aa1d0efb43 100644 --- a/crates/astria-core/src/generated/astria.bundle.v1alpha1.rs +++ b/crates/astria-core/src/generated/astria.bundle.v1alpha1.rs @@ -40,6 +40,33 @@ impl ::prost::Name for Bundle { ::prost::alloc::format!("astria.bundle.v1alpha1.{}", Self::NAME) } } +/// The AuctionResult message is submitted by the Auctioneer to the rollup as a +/// `RollupDataSubmission` on the sequencer. +/// The rollup will verify the signature and public key against its configuration, +/// then unbundle the body into rollup transactions and execute them first in the +/// block. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct AuctionResult { + /// The Ed25519 signature of the Auctioneer, to be verified against config by the + /// rollup. + #[prost(bytes = "bytes", tag = "1")] + pub signature: ::prost::bytes::Bytes, + /// The Ed25519 public key of the Auctioneer, to be verified against config by the + /// rollup. + #[prost(bytes = "bytes", tag = "2")] + pub public_key: ::prost::bytes::Bytes, + /// The bundle that was allocated the winning slot by the Auctioneer. + #[prost(message, optional, tag = "3")] + pub allocation: ::core::option::Option, +} +impl ::prost::Name for AuctionResult { + const NAME: &'static str = "AuctionResult"; + const PACKAGE: &'static str = "astria.bundle.v1alpha1"; + fn full_name() -> ::prost::alloc::string::String { + ::prost::alloc::format!("astria.bundle.v1alpha1.{}", Self::NAME) + } +} #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetBundleStreamResponse { diff --git a/crates/astria-core/src/generated/astria.bundle.v1alpha1.serde.rs b/crates/astria-core/src/generated/astria.bundle.v1alpha1.serde.rs index 0ae7a566fd..dd590eeb80 100644 --- a/crates/astria-core/src/generated/astria.bundle.v1alpha1.serde.rs +++ b/crates/astria-core/src/generated/astria.bundle.v1alpha1.serde.rs @@ -1,3 +1,135 @@ +impl serde::Serialize for AuctionResult { + #[allow(deprecated)] + fn serialize(&self, serializer: S) -> std::result::Result + where + S: serde::Serializer, + { + use serde::ser::SerializeStruct; + let mut len = 0; + if !self.signature.is_empty() { + len += 1; + } + if !self.public_key.is_empty() { + len += 1; + } + if self.allocation.is_some() { + len += 1; + } + let mut struct_ser = serializer.serialize_struct("astria.bundle.v1alpha1.AuctionResult", len)?; + if !self.signature.is_empty() { + #[allow(clippy::needless_borrow)] + struct_ser.serialize_field("signature", pbjson::private::base64::encode(&self.signature).as_str())?; + } + if !self.public_key.is_empty() { + #[allow(clippy::needless_borrow)] + struct_ser.serialize_field("publicKey", pbjson::private::base64::encode(&self.public_key).as_str())?; + } + if let Some(v) = self.allocation.as_ref() { + struct_ser.serialize_field("allocation", v)?; + } + struct_ser.end() + } +} +impl<'de> serde::Deserialize<'de> for AuctionResult { + #[allow(deprecated)] + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + const FIELDS: &[&str] = &[ + "signature", + "public_key", + "publicKey", + "allocation", + ]; + + #[allow(clippy::enum_variant_names)] + enum GeneratedField { + Signature, + PublicKey, + Allocation, + } + impl<'de> serde::Deserialize<'de> for GeneratedField { + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + struct GeneratedVisitor; + + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = GeneratedField; + + fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(formatter, "expected one of: {:?}", &FIELDS) + } + + #[allow(unused_variables)] + fn visit_str(self, value: &str) -> std::result::Result + where + E: serde::de::Error, + { + match value { + "signature" => Ok(GeneratedField::Signature), + "publicKey" | "public_key" => Ok(GeneratedField::PublicKey), + "allocation" => Ok(GeneratedField::Allocation), + _ => Err(serde::de::Error::unknown_field(value, FIELDS)), + } + } + } + deserializer.deserialize_identifier(GeneratedVisitor) + } + } + struct GeneratedVisitor; + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = AuctionResult; + + fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + formatter.write_str("struct astria.bundle.v1alpha1.AuctionResult") + } + + fn visit_map(self, mut map_: V) -> std::result::Result + where + V: serde::de::MapAccess<'de>, + { + let mut signature__ = None; + let mut public_key__ = None; + let mut allocation__ = None; + while let Some(k) = map_.next_key()? { + match k { + GeneratedField::Signature => { + if signature__.is_some() { + return Err(serde::de::Error::duplicate_field("signature")); + } + signature__ = + Some(map_.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) + ; + } + GeneratedField::PublicKey => { + if public_key__.is_some() { + return Err(serde::de::Error::duplicate_field("publicKey")); + } + public_key__ = + Some(map_.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) + ; + } + GeneratedField::Allocation => { + if allocation__.is_some() { + return Err(serde::de::Error::duplicate_field("allocation")); + } + allocation__ = map_.next_value()?; + } + } + } + Ok(AuctionResult { + signature: signature__.unwrap_or_default(), + public_key: public_key__.unwrap_or_default(), + allocation: allocation__, + }) + } + } + deserializer.deserialize_struct("astria.bundle.v1alpha1.AuctionResult", FIELDS, GeneratedVisitor) + } +} impl serde::Serialize for BaseBlock { #[allow(deprecated)] fn serialize(&self, serializer: S) -> std::result::Result diff --git a/proto/executionapis/astria/bundle/v1alpha1/bundle.proto b/proto/executionapis/astria/bundle/v1alpha1/bundle.proto index f4d350803f..08c8b461ea 100644 --- a/proto/executionapis/astria/bundle/v1alpha1/bundle.proto +++ b/proto/executionapis/astria/bundle/v1alpha1/bundle.proto @@ -24,6 +24,22 @@ message Bundle { bytes prev_rollup_block_hash = 4; } +// The AuctionResult message is submitted by the Auctioneer to the rollup as a +// `RollupDataSubmission` on the sequencer. +// The rollup will verify the signature and public key against its configuration, +// then unbundle the body into rollup transactions and execute them first in the +// block. +message AuctionResult { + // The Ed25519 signature of the Auctioneer, to be verified against config by the + // rollup. + bytes signature = 1; + // The Ed25519 public key of the Auctioneer, to be verified against config by the + // rollup. + bytes public_key = 2; + // The bundle that was allocated the winning slot by the Auctioneer. + Bundle allocation = 3; +} + message GetBundleStreamResponse { Bundle bundle = 1; }