Skip to content

Commit

Permalink
keccak self mut (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
edg-l authored Oct 27, 2023
1 parent f82ed76 commit 03cd09b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/erc20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl StarkNetSyscallHandler for SyscallHandler {
}

fn keccak(
&self,
&mut self,
input: &[u64],
_gas: &mut u128,
) -> SyscallResult<cairo_native::starknet::U256> {
Expand Down
2 changes: 1 addition & 1 deletion examples/starknet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl StarkNetSyscallHandler for SyscallHandler {
}

fn keccak(
&self,
&mut self,
input: &[u64],
_gas: &mut u128,
) -> SyscallResult<cairo_native::starknet::U256> {
Expand Down
2 changes: 1 addition & 1 deletion src/starknet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pub trait StarkNetSyscallHandler {
remaining_gas: &mut u128,
) -> SyscallResult<()>;

fn keccak(&self, input: &[u64], remaining_gas: &mut u128) -> SyscallResult<U256>;
fn keccak(&mut self, input: &[u64], remaining_gas: &mut u128) -> SyscallResult<U256>;

// TODO: secp256k1 syscalls
fn secp256k1_add(
Expand Down
6 changes: 5 additions & 1 deletion tests/starknet/keccak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ impl StarkNetSyscallHandler for SyscallHandler {
Ok(())
}

fn keccak(&self, input: &[u64], gas: &mut u128) -> SyscallResult<cairo_native::starknet::U256> {
fn keccak(
&mut self,
input: &[u64],
gas: &mut u128,
) -> SyscallResult<cairo_native::starknet::U256> {
println!("Called `keccak({input:?})` from MLIR.");
*gas -= 1000;
Ok(U256(Felt252::from(1234567890).to_le_bytes()))
Expand Down

0 comments on commit 03cd09b

Please sign in to comment.