Skip to content

Commit f56deda

Browse files
apollo_protobuf: split InvokeV3 to InvokeV3WithProof and InvokeV3WithoutProof
1 parent 51e2863 commit f56deda

File tree

6 files changed

+43
-14
lines changed

6 files changed

+43
-14
lines changed

crates/apollo_protobuf/src/converters/rpc_transaction.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,29 +112,34 @@ impl From<RpcDeployAccountTransactionV3> for protobuf::DeployAccountV3 {
112112
}
113113
}
114114

115-
impl TryFrom<protobuf::InvokeV3> for RpcInvokeTransactionV3 {
115+
impl TryFrom<protobuf::InvokeV3WithProof> for RpcInvokeTransactionV3 {
116116
type Error = ProtobufConversionError;
117-
fn try_from(mut value: protobuf::InvokeV3) -> Result<Self, Self::Error> {
117+
fn try_from(mut value: protobuf::InvokeV3WithProof) -> Result<Self, Self::Error> {
118118
// Extract proof first, since `starknet_api::transaction::InvokeTransactionV3` does not
119119
// carry a `proof` field.
120120
let proof = Proof::from(std::mem::take(&mut value.proof));
121121

122-
let snapi_invoke: InvokeTransactionV3 = value.try_into()?;
122+
let snapi_invoke: InvokeTransactionV3 = value
123+
.invoke
124+
.ok_or(ProtobufConversionError::MissingField {
125+
field_description: "InvokeV3WithProof::invoke",
126+
})?
127+
.try_into()?;
123128

124129
// This conversion can fail only if the resource_bounds are not AllResources.
125130
Ok(Self { proof, ..snapi_invoke.try_into().map_err(|_| DEPRECATED_RESOURCE_BOUNDS_ERROR)? })
126131
}
127132
}
128133

129-
impl From<RpcInvokeTransactionV3> for protobuf::InvokeV3 {
134+
impl From<RpcInvokeTransactionV3> for protobuf::InvokeV3WithProof {
130135
fn from(mut value: RpcInvokeTransactionV3) -> Self {
131136
// Extract proof first, since `starknet_api::transaction::InvokeTransactionV3` does not
132137
// carry a `proof` field.
133138
let proof = Arc::unwrap_or_clone(std::mem::take(&mut value.proof).0);
134139

135140
let snapi_invoke: InvokeTransactionV3 = value.into();
136141

137-
Self { proof, ..snapi_invoke.into() }
142+
Self { invoke: Some(snapi_invoke.into()), proof }
138143
}
139144
}
140145

crates/apollo_protobuf/src/converters/transaction.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,6 @@ impl From<InvokeTransactionV3> for protobuf::InvokeV3 {
695695
.iter()
696696
.map(|proof_fact| (*proof_fact).into())
697697
.collect(),
698-
// TODO(AvivG): Understand in what flow this is used. Is info lost?
699-
proof: vec![],
700698
}
701699
}
702700
}

crates/apollo_protobuf/src/proto/p2p/proto/consensus/consensus.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ message ConsensusTransaction {
1010
oneof txn {
1111
DeclareV3WithClass declare_v3 = 1;
1212
DeployAccountV3 deploy_account_v3 = 2;
13-
InvokeV3 invoke_v3 = 3;
13+
InvokeV3WithProof invoke_v3 = 3;
1414
L1HandlerV0 l1_handler = 4;
1515
}
1616
Hash transaction_hash = 5;

crates/apollo_protobuf/src/proto/p2p/proto/mempool/transaction.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ message MempoolTransaction {
1313
oneof txn {
1414
DeclareV3WithClass declare_v3 = 1;
1515
DeployAccountV3 deploy_account_v3 = 2;
16-
InvokeV3 invoke_v3 = 3;
16+
InvokeV3WithProof invoke_v3 = 3;
1717
}
1818
Hash transaction_hash = 4;
1919
}

crates/apollo_protobuf/src/proto/p2p/proto/transaction.proto

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ message DeclareV3WithClass {
4949

5050

5151
// see https://external.integration.starknet.io/feeder_gateway/get_transaction?transactionHash=0x41906f1c314cca5f43170ea75d3b1904196a10101190d2b12a41cc61cfd17c
52+
// An invoke V3 transaction without client-side proof (only contains proof_facts).
5253
message InvokeV3 {
5354
Address sender = 1;
5455
AccountSignature signature = 2;
@@ -61,7 +62,13 @@ message InvokeV3 {
6162
VolitionDomain fee_data_availability_mode = 9;
6263
Felt252 nonce = 10;
6364
repeated Felt252 proof_facts = 11;
64-
repeated uint32 proof = 12;
65+
}
66+
67+
// An invoke V3 transaction with client-side proof.
68+
// Used in consensus and mempool contexts where proof is included.
69+
message InvokeV3WithProof {
70+
InvokeV3 invoke = 1;
71+
repeated uint32 proof = 2;
6572
}
6673

6774
// see https://external.integration.starknet.io/feeder_gateway/get_transaction?transactionHash=0x29fd7881f14380842414cdfdd8d6c0b1f2174f8916edcfeb1ede1eb26ac3ef0

crates/apollo_protobuf/src/protobuf/protoc_output.rs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,17 @@ pub struct BlockProof {
8282
#[allow(clippy::derive_partial_eq_without_eq)]
8383
#[derive(Clone, PartialEq, ::prost::Message)]
8484
pub struct Fin {}
85-
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
85+
#[derive(
86+
Clone,
87+
Copy,
88+
Debug,
89+
PartialEq,
90+
Eq,
91+
Hash,
92+
PartialOrd,
93+
Ord,
94+
::prost::Enumeration
95+
)]
8696
#[repr(i32)]
8797
pub enum L1DataAvailabilityMode {
8898
Calldata = 0,
@@ -280,6 +290,7 @@ pub struct DeclareV3WithClass {
280290
pub class: ::core::option::Option<Cairo1Class>,
281291
}
282292
/// see <https://external.integration.starknet.io/feeder_gateway/get_transaction?transactionHash=0x41906f1c314cca5f43170ea75d3b1904196a10101190d2b12a41cc61cfd17c>
293+
/// An invoke V3 transaction without client-side proof (only contains proof_facts).
283294
#[allow(clippy::derive_partial_eq_without_eq)]
284295
#[derive(Clone, PartialEq, ::prost::Message)]
285296
pub struct InvokeV3 {
@@ -305,7 +316,15 @@ pub struct InvokeV3 {
305316
pub nonce: ::core::option::Option<Felt252>,
306317
#[prost(message, repeated, tag = "11")]
307318
pub proof_facts: ::prost::alloc::vec::Vec<Felt252>,
308-
#[prost(uint32, repeated, tag = "12")]
319+
}
320+
/// An invoke V3 transaction with client-side proof.
321+
/// Used in consensus and mempool contexts where proof is included.
322+
#[allow(clippy::derive_partial_eq_without_eq)]
323+
#[derive(Clone, PartialEq, ::prost::Message)]
324+
pub struct InvokeV3WithProof {
325+
#[prost(message, optional, tag = "1")]
326+
pub invoke: ::core::option::Option<InvokeV3>,
327+
#[prost(uint32, repeated, tag = "2")]
309328
pub proof: ::prost::alloc::vec::Vec<u32>,
310329
}
311330
/// see <https://external.integration.starknet.io/feeder_gateway/get_transaction?transactionHash=0x29fd7881f14380842414cdfdd8d6c0b1f2174f8916edcfeb1ede1eb26ac3ef0>
@@ -353,7 +372,7 @@ pub mod consensus_transaction {
353372
#[prost(message, tag = "2")]
354373
DeployAccountV3(super::DeployAccountV3),
355374
#[prost(message, tag = "3")]
356-
InvokeV3(super::InvokeV3),
375+
InvokeV3(super::InvokeV3WithProof),
357376
#[prost(message, tag = "4")]
358377
L1Handler(super::L1HandlerV0),
359378
}
@@ -950,7 +969,7 @@ pub mod mempool_transaction {
950969
#[prost(message, tag = "2")]
951970
DeployAccountV3(super::DeployAccountV3),
952971
#[prost(message, tag = "3")]
953-
InvokeV3(super::InvokeV3),
972+
InvokeV3(super::InvokeV3WithProof),
954973
}
955974
}
956975
#[allow(clippy::derive_partial_eq_without_eq)]

0 commit comments

Comments
 (0)