From b9bf28c0c46204a0076e9216ce8591c25a336a67 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..bd56ae4175 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 Allocation 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 Allocation { + /// 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 payload: ::core::option::Option, +} +impl ::prost::Name for Allocation { + const NAME: &'static str = "Allocation"; + 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..12c3b97cae 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 Allocation { + #[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.payload.is_some() { + len += 1; + } + let mut struct_ser = serializer.serialize_struct("astria.bundle.v1alpha1.Allocation", 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.payload.as_ref() { + struct_ser.serialize_field("payload", v)?; + } + struct_ser.end() + } +} +impl<'de> serde::Deserialize<'de> for Allocation { + #[allow(deprecated)] + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + const FIELDS: &[&str] = &[ + "signature", + "public_key", + "publicKey", + "payload", + ]; + + #[allow(clippy::enum_variant_names)] + enum GeneratedField { + Signature, + PublicKey, + Payload, + } + 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), + "payload" => Ok(GeneratedField::Payload), + _ => Err(serde::de::Error::unknown_field(value, FIELDS)), + } + } + } + deserializer.deserialize_identifier(GeneratedVisitor) + } + } + struct GeneratedVisitor; + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = Allocation; + + fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + formatter.write_str("struct astria.bundle.v1alpha1.Allocation") + } + + 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 payload__ = 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::Payload => { + if payload__.is_some() { + return Err(serde::de::Error::duplicate_field("payload")); + } + payload__ = map_.next_value()?; + } + } + } + Ok(Allocation { + signature: signature__.unwrap_or_default(), + public_key: public_key__.unwrap_or_default(), + payload: payload__, + }) + } + } + deserializer.deserialize_struct("astria.bundle.v1alpha1.Allocation", 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..3bdc550846 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 Allocation 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 Allocation { + // 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 payload = 3; +} + message GetBundleStreamResponse { Bundle bundle = 1; }