feat: create bounded vector for sign request args#2165
feat: create bounded vector for sign request args#2165
Conversation
dddaec2 to
7d172e1
Compare
| schemars(with = "[u8; 32]"), | ||
| borsh(schema(with_funcs( | ||
| declaration = "<[u8; 32] as ::borsh::BorshSchema>::declaration", | ||
| definitions = "<[u8; 32] as ::borsh::BorshSchema>::add_definitions_recursively" | ||
| ),)) | ||
| schemars( | ||
| with = "hex_serde::HexString<ECDSA_PAYLOAD_SIZE_BYTES, ECDSA_PAYLOAD_SIZE_BYTES>" | ||
| ) | ||
| )] | ||
| Bytes<32, 32>, | ||
| BoundedVec<u8, ECDSA_PAYLOAD_SIZE_BYTES, ECDSA_PAYLOAD_SIZE_BYTES>, | ||
| ), | ||
| Eddsa( | ||
| #[serde(with = "hex_serde")] | ||
| #[cfg_attr( | ||
| all(feature = "abi", not(target_arch = "wasm32")), | ||
| schemars(with = "Vec<u8>"), | ||
| borsh(schema(with_funcs( | ||
| declaration = "<Vec<u8> as ::borsh::BorshSchema>::declaration", | ||
| definitions = "<Vec<u8> as ::borsh::BorshSchema>::add_definitions_recursively" | ||
| ),)) |
There was a problem hiding this comment.
There was previously a bug in the schema definition. We expect a hex string, but declared sequence of bytes (vector)
| #[derive(Debug, BorshSerialize, BorshDeserialize)] | ||
| struct StaleData { | ||
| pending_signature_requests_pre_upgrade: LookupMap<v3_4_1_state::SignatureRequest, YieldIndex>, | ||
| } | ||
|
|
||
| impl StaleData { | ||
| fn new() -> Self { | ||
| Self { | ||
| pending_signature_requests_pre_upgrade: LookupMap::new( | ||
| StorageKey::PendingSignatureRequestsV2, | ||
| ), | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
This migration step is needed because the new BoundedVec deosn't have idential borsh/hash implementation.
There was a problem hiding this comment.
Most of the implementation is taken from https://github.com/ergoplatform/bounded-vec/blob/develop/src/bounded_vec.rs (license allows this).
Some small changes have been made, such as not implementing AsMut since that can break the invariants.
Borsh and scehma implementations have also been added for ABI generation.
| @@ -2633,12 +2638,7 @@ expression: abi | |||
| ], | |||
| "properties": { | |||
| "Eddsa": { | |||
| "type": "array", | |||
| "items": { | |||
| "type": "integer", | |||
| "format": "uint8", | |||
| "minimum": 0.0 | |||
| } | |||
| "$ref": "#/definitions/HexString_Min32_Max1232" | |||
| } | |||
There was a problem hiding this comment.
There was previously a bug in the schema definition. We expect a hex string, but declared sequence of bytes (vector) in the schema
|
PR title type suggestion: This PR introduces a new bounded collections library with substantial new functionality (~2,000 lines of code in a new crate) integrated throughout the codebase for type-safe collection handling. The type prefix should probably be Suggested title: |
|
PR title type suggestion: This PR introduces new crates and types (bounded-collections, non-empty-collections) with API changes and functional impact across the system, so the type prefix should probably be 'feat:' instead of 'chore:'. Suggested title: 'feat: create bounded vector and non-empty collections for sign request args and foreign chains' |
|
@claude please review |
PR Review: chore: create bounded vector for sign request argsI reviewed the full diff focusing on correctness, migration safety, and backward compatibility. SummaryThis PR replaces the ad-hoc
Critical Issues FoundNone. The migration strategy is sound:
Minor Observations (non-blocking)
✅ Approved — the migration is well-structured with proper fallback handling for in-flight requests. |
|
Superseded by #2199 |
closes #2186