Skip to content

Commit dd58a19

Browse files
committed
change Proof inner representation from Vec<u32> to Vec<u8>, align proof type with recent p2p spec
1 parent ee81905 commit dd58a19

File tree

6 files changed

+10
-29
lines changed

6 files changed

+10
-29
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2626

2727
- The v10 JSON-RPC endpoint now supports final JSON-RPC v0.10.1 spec.
2828
- `blockifier` has been upgraded to 0.18.0-dev.1, ensuring correctness of execution results on Starknet 0.14.2.
29+
- The `proof` field in broadcasted invoke v3 transactions is now a base64-encoded byte blob (`Vec<u8>`) instead of base64-encoded packed `u32` values (`Vec<u32>`). This reflects the upstream change to use compressed proofs. The P2P wire format changes from `repeated uint32` to `bytes`.
2930

3031
## [0.22.0-beta.3] - 2026-03-11
3132

crates/common/src/lib.rs

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -697,10 +697,9 @@ pub fn calculate_class_commitment_leaf_hash(
697697
)
698698
}
699699

700-
/// A SNOS stwo proof, serialized as a base64-encoded string of big-endian
701-
/// packed `u32` values.
700+
/// A SNOS stwo proof, serialized as a base64-encoded byte string.
702701
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
703-
pub struct Proof(pub Vec<u32>);
702+
pub struct Proof(pub Vec<u8>);
704703

705704
impl Proof {
706705
pub fn is_empty(&self) -> bool {
@@ -712,8 +711,7 @@ impl serde::Serialize for Proof {
712711
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
713712
use base64::Engine;
714713

715-
let bytes: Vec<u8> = self.0.iter().flat_map(|v| v.to_be_bytes()).collect();
716-
let encoded = base64::engine::general_purpose::STANDARD.encode(&bytes);
714+
let encoded = base64::engine::general_purpose::STANDARD.encode(&self.0);
717715
serializer.serialize_str(&encoded)
718716
}
719717
}
@@ -729,17 +727,7 @@ impl<'de> serde::Deserialize<'de> for Proof {
729727
let bytes = base64::engine::general_purpose::STANDARD
730728
.decode(&s)
731729
.map_err(serde::de::Error::custom)?;
732-
if bytes.len() % 4 != 0 {
733-
return Err(serde::de::Error::custom(format!(
734-
"proof base64 decoded length {} is not a multiple of 4",
735-
bytes.len()
736-
)));
737-
}
738-
let values = bytes
739-
.chunks_exact(4)
740-
.map(|chunk| u32::from_be_bytes(chunk.try_into().unwrap()))
741-
.collect();
742-
Ok(Proof(values))
730+
Ok(Proof(bytes))
743731
}
744732
}
745733

@@ -811,7 +799,7 @@ mod tests {
811799

812800
#[test]
813801
fn round_trip() {
814-
let proof = Proof(vec![0, 123, 456]);
802+
let proof = Proof(vec![0, 0, 0, 0, 0, 0, 0, 123, 0, 0, 1, 200]);
815803
let json = serde_json::to_string(&proof).unwrap();
816804
assert_eq!(json, r#""AAAAAAAAAHsAAAHI""#);
817805
let deserialized: Proof = serde_json::from_str(&json).unwrap();
@@ -830,13 +818,6 @@ mod tests {
830818
assert!(result.is_err());
831819
}
832820

833-
#[test]
834-
fn non_multiple_of_4_length_returns_error() {
835-
// 3 bytes is not a multiple of 4
836-
let result = serde_json::from_str::<Proof>(r#""AAAA""#); // decodes to 3 bytes
837-
assert!(result.is_err());
838-
}
839-
840821
#[test]
841822
fn empty_proof_serializes_to_empty_string() {
842823
let proof = Proof::default();

crates/p2p_proto/proto/transaction.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ message InvokeV3 {
6868
// Used in consensus and mempool contexts where proof is included.
6969
message InvokeV3WithProof {
7070
InvokeV3 invoke = 1;
71-
repeated uint32 proof = 2;
71+
bytes proof = 2;
7272
}
7373

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

crates/p2p_proto/src/transaction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub struct InvokeV3 {
8787
#[protobuf(name = "crate::proto::transaction::InvokeV3WithProof")]
8888
pub struct InvokeV3WithProof {
8989
pub invoke: InvokeV3,
90-
pub proof: Vec<u32>,
90+
pub proof: Vec<u8>,
9191
}
9292

9393
#[derive(Debug, Clone, PartialEq, Eq, ToProtobuf, TryFromProtobuf, Dummy)]

crates/rpc/fixtures/0.10.0/broadcasted_transactions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
"0xabc",
187187
"0xdef"
188188
],
189-
"proof": "AAAACwAAABY="
189+
"proof": "CxY="
190190
},
191191
{
192192
"type": "DEPLOY_ACCOUNT",

crates/rpc/src/dto/primitives.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,8 +831,7 @@ mod pathfinder_common_types {
831831
fn serialize(&self, serializer: Serializer) -> Result<crate::dto::Ok, crate::dto::Error> {
832832
use base64::Engine;
833833

834-
let bytes: Vec<u8> = self.0.iter().flat_map(|v| v.to_be_bytes()).collect();
835-
let encoded = base64::engine::general_purpose::STANDARD.encode(&bytes);
834+
let encoded = base64::engine::general_purpose::STANDARD.encode(&self.0);
836835
serializer.serialize_str(&encoded)
837836
}
838837
}

0 commit comments

Comments
 (0)