cairo: Declare fail: Error: OSError: [Errno 8] Exec format error
Bug Report
Cairo version: cairo: v0.12.0 starknet: v2.0.0
Current behavior:
Declare fail when I set allowed-libfuncs-list.name = "all"
> starknet declare --contract nft.json --account fico
Error: OSError: [Errno 8] Exec format error: '/Users/fico/cairo_venv/lib/python3.9/site-packages/starkware/starknet/compiler/v1/bin/starknet-sierra-compile'
Expected behavior: Declare success
Steps to reproduce:
starknet-compile src/nft.cairo --allowed-libfuncs-list-name all > nft.jsonstarknet declare --contract nft.json --account fico
Related code:
nft.cairo
use keccak::keccak_u256s_be_inputs;
fn sign(self: @ContractState, user: ContractAddress) -> u256 {
let chain_id = get_tx_info().unbox().chain_id; /// felt252
let nft_core = contract_address_to_felt252(contract_address_const::<0>()); /// ContractAddress
let mut input = Default::default();
input.append(chain_id.into());
input.append(nft_core.into());
input.append(contract_address_to_felt252(user).into());
keccak::keccak_u256s_le_inputs(input.span())
}
Scarb.toml
[package]
name = "nft"
version = "0.1.0"
[dependencies]
starknet = "2.0.0"
[[target.starknet-contract]]
sierra = true
casm = true
allowed-libfuncs-list.name = "all"
Other information:
OS: MacOS (Apple M1 Max)
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 15 (2 by maintainers)
Hi @fico308, here is the description of your error and some troubleshooting steps to follow.
Note that the cairo-lang is now deprecated and you should use Starkli combined with Scarb instead.
Follow the instructions in the Starknet Book to create, compile, and deploy your first contract.
As you previously said, you will not be able to deploy on networks with the
--allowed-libfuncs-list-name alloption.This error is generated when cairo-lang attempts to compile your Sierra code using an imported Rust binary, ‘starknet-sierra-compile’. However, in some instances, the imported binary may not be compatible with your system architecture.
The solution is to replace the incompatible Rust binary with a locally built version. The following steps can guide you through this process:
Build the ‘starknet-sierra-compile’ binary locally. We did this before when we set up our environment by cloning the starknet repository and building the binary. If you have not done this yet, please refer to the Setting Up Your Environment subchapter.
Replace the incompatible binary in the Python package. The locally built ‘starknet-sierra-compile’ binary can be moved into the Python package directory. Here’s an example of how to do this:
@fico308 if you want to hash things in a Starknet-native way (keccak is more expensive on SN), then you can use
pedersenofposeidon. To use pedersen you can use the LegacyHash traitOk, so maybe it’s the second reason for the error "Error: code=InvalidContractClass, message=“Compiled versions older than 1.1.0 are not supported. Got version 1.2.1.” Summary: