Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ More expansive patch notes and explanations may be found in the specific [pathfi
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Changed

- 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.

## [0.22.0] - 2026-03-19

### Fixed
Expand Down
29 changes: 5 additions & 24 deletions crates/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,10 +697,9 @@ pub fn calculate_class_commitment_leaf_hash(
)
}

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

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

let bytes: Vec<u8> = self.0.iter().flat_map(|v| v.to_be_bytes()).collect();
let encoded = base64::engine::general_purpose::STANDARD.encode(&bytes);
let encoded = base64::engine::general_purpose::STANDARD.encode(&self.0);
serializer.serialize_str(&encoded)
}
}
Expand All @@ -729,17 +727,7 @@ impl<'de> serde::Deserialize<'de> for Proof {
let bytes = base64::engine::general_purpose::STANDARD
.decode(&s)
.map_err(serde::de::Error::custom)?;
if bytes.len() % 4 != 0 {
return Err(serde::de::Error::custom(format!(
"proof base64 decoded length {} is not a multiple of 4",
bytes.len()
)));
}
let values = bytes
.chunks_exact(4)
.map(|chunk| u32::from_be_bytes(chunk.try_into().unwrap()))
.collect();
Ok(Proof(values))
Ok(Proof(bytes))
}
}

Expand Down Expand Up @@ -811,7 +799,7 @@ mod tests {

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

#[test]
fn non_multiple_of_4_length_returns_error() {
// 3 bytes is not a multiple of 4
let result = serde_json::from_str::<Proof>(r#""AAAA""#); // decodes to 3 bytes
assert!(result.is_err());
}

#[test]
fn empty_proof_serializes_to_empty_string() {
let proof = Proof::default();
Expand Down
2 changes: 1 addition & 1 deletion crates/p2p_proto/proto/transaction.proto
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ message InvokeV3 {
// Used in consensus and mempool contexts where proof is included.
message InvokeV3WithProof {
InvokeV3 invoke = 1;
repeated uint32 proof = 2;
bytes proof = 2;
}

// see https://external.integration.starknet.io/feeder_gateway/get_transaction?transactionHash=0x29fd7881f14380842414cdfdd8d6c0b1f2174f8916edcfeb1ede1eb26ac3ef0
Expand Down
2 changes: 1 addition & 1 deletion crates/p2p_proto/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub struct InvokeV3 {
#[protobuf(name = "crate::proto::transaction::InvokeV3WithProof")]
pub struct InvokeV3WithProof {
pub invoke: InvokeV3,
pub proof: Vec<u32>,
pub proof: Vec<u8>,
}

#[derive(Debug, Clone, PartialEq, Eq, ToProtobuf, TryFromProtobuf, Dummy)]
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/fixtures/0.10.0/broadcasted_transactions.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
"0xabc",
"0xdef"
],
"proof": "AAAACwAAABY="
"proof": "CxY="
},
{
"type": "DEPLOY_ACCOUNT",
Expand Down
3 changes: 1 addition & 2 deletions crates/rpc/src/dto/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,7 @@ mod pathfinder_common_types {
fn serialize(&self, serializer: Serializer) -> Result<crate::dto::Ok, crate::dto::Error> {
use base64::Engine;

let bytes: Vec<u8> = self.0.iter().flat_map(|v| v.to_be_bytes()).collect();
let encoded = base64::engine::general_purpose::STANDARD.encode(&bytes);
let encoded = base64::engine::general_purpose::STANDARD.encode(&self.0);
serializer.serialize_str(&encoded)
}
}
Expand Down
Loading