Open enitrat opened 1 month ago
I am applying to this issue via OnlyDust platform.
Hi, I am Cairo dev with lots of experience contributing to Cairo projects, my OD profile is a witness to this. This feat is right within my comfort zone.
I have had experience working on projects were bitshift operations were implemented I can use those as a reference for implementing this.
After implementing this, I will write a robust unit test and ensure all test case are covered and the feat behaves as expected.
I am applying to this issue via OnlyDust platform.
Hello, I am Manuel, a process engineer and web3 developer. I have participated in Starknet Bootcamps, ETHGlobal and am an Elite winner of Speedrunstark. I have a high capacity to solve problems. I am a member of the DojoCoding community. I hope this issue is assigned to me. I am available to work immediately to achieve what is required in the shortest time possible.
To address the requirements of the issue, I will:
POW_2
containing powers of two up to 256.p
is less than or equal to 255:
p <= 255
, use the corresponding value from the POW_2
lookup table for optimization.p > 255
, fallback to using the pow
function.BitSize::<u256>::bits() - One::<T>::one()
.I am applying to this issue via OnlyDust platform.
I have been a rust and zk dev before and i have implemented lookup tables for zk cryptography . I think that will help me in this issue
I am applying to this issue via OnlyDust platform.
I am a newcomer in the blockchain dev world, and I'd really like to be given a chance to complete my first OnlyDust contribution. I have experience with Node Guardians's brainfvck VM in Cairo, where I used bitshift operations a lot, as well as the cairo-profiler. Thank you
I would create a look up cable to store powers of two from w~0 to 2~255 in an array pow_2. Then check the value of p. And of course communicate if I encounter any problem
I am applying to this issue via OnlyDust platform.
I have some experience in Cairo, mostly porting Solidity ERCs to Cairo: https://github.com/carbonable-labs/cairo-erc-7496 https://github.com/carbonable-labs/cairo-erc-7498
I will carefully implement the required optimization by leveraging a lookup table for powers of 2 <= 255. I will make sure to follow the hint given to generically obtain the value 255 from any type using bitsize introspection.
The maintainer enitrat has assigned augustin-v to this issue via OnlyDust Platform. Good luck!
for the powers of two up to 256, we can define a lookup table and use that lookup table to execute bitshift operations, instead of calling the expensive cairo function
pow
.POW_2
pow
.Hint: In a generic context, you can get the value
255
of type T by doingBitSize::<u256>::bits() - One::<T>::one()
- make sure you're using the right types for that.https://github.com/kkrt-labs/kakarot-ssj/blob/b1f7f8c13be38edc081f0738c188561240c098b4/crates/utils/src/math.cairo#L195-L212
https://github.com/kkrt-labs/kakarot-ssj/blob/b1f7f8c13be38edc081f0738c188561240c098b4/crates/utils/src/math.cairo#L242-L255