starknet-devnet-rs
starknet-devnet-rs copied to clipboard
Remove Copy trait from Felt
Copy trait must be removed from
#[derive(Debug, Default, Copy, Clone, Eq, PartialEq, Hash, PartialOrd, Ord)]
pub struct Felt(pub(crate) [u8; 32]);
What is the motivation for this? I see that FieldElement of starknet-rs has Copy implemented
To avoid copying 32 bytes of data when the idea is just to move the element
this looks interesting! i would love to work on this
@g4titanx please report frequently on progress!
okay
hello @ivpavici, as expected removing the copy trait from Felt led to a chain of issues. some of the errors I got during compilation were from the custom types that implemented the copy trait with the Felt type in their field. i had to remove their copy traits tho.
now one error I am stuck with is "type mismatch resolving <Iter<'_, Felt> as IntoIterator>::Item == Felt " in this section of transaction.rs
https://github.com/0xSpaceShard/starknet-devnet-rs/blob/9162df948ffc444520ba1c7397d9e8564e8dc576/crates/starknet-devnet-types/src/rpc/transactions.rs#L692-L693
Of course, using a Vec<&Felt> for calldata_to_hash can be a solution, but it caused a series errors in the program, just like adding the cloned() method on line 693. I'm currently stuck on this issue, and I feel like I'm missing something important. i would be so glad if you can offer an helping hand
Hello @ivpavici, any update on this
@g4titanx in fact this issue is not an easy one the idea is to remove the copying of 32 bytes, where moving of the variable was intended.
i agree. it's not as easy as I thought. but, I will give it all I can
hello @ivpavici, as expected removing the copy trait from Felt led to a chain of issues. some of the errors I got during compilation were from the custom types that implemented the copy trait with the Felt type in their field. i had to remove their copy traits tho.
now one error I am stuck with is "type mismatch resolving
<Iter<'_, Felt> as IntoIterator>::Item == Felt" in this section of transaction.rshttps://github.com/0xSpaceShard/starknet-devnet-rs/blob/9162df948ffc444520ba1c7397d9e8564e8dc576/crates/starknet-devnet-types/src/rpc/transactions.rs#L692-L693
tried different approach to fixing this issue. i am open to ideas how I can advance.
@g4titanx can you open a PR with your approach? It's hard to tell like this what you tried
Closing as this doesn't give any significant improvements