paritytech / libsecp256k1

Pure Rust Implementation of secp256k1.
Apache License 2.0
175 stars 84 forks source link

Not able to compile code with solana & exceed computation units error while calling verify function #92

Open jayeshsupra opened 2 years ago

jayeshsupra commented 2 years ago

hello,

  1. i have used libsecp256k1 in my solana program and compiled code for same.

code has been successfully compiled but with one error as stack exceeded max limit: error message: Error: Function _ZN17libsecp256k1_core6ecmult13ECMultContext6ecmult17h70a883a093cf3492E Stack offset of -4592 exceeded max offset of -4096 by 496 bytes, please minimize large stack variables ( detailed shown in below snap )

image

  1. after successfully deploying a code with one compilation error i'm calling verify function from libsecp256k1 but is giving me an error as Program eY1fuXT4ibaEXKwxg2nCxRfhgT8whRpmDGCHRrdYGcE consumed 200000 of 200000 compute units, even-though i have left with 156539 units out of 200000 which is max limit for computation in solana.

image

i have raised same issue with solana dev support as well, and after suggesting some solutions at last he has mentioned that they can't increase computation limit you might have to contact library for same.

can you please look into this issue?

rkonda20 commented 2 years ago

I am unable to compile with solana too

Compiling libsecp256k1 v0.6.0 error: could not compile libsecp256k1

Caused by: process didn't exit successfully: rustc --crate-name libsecp256k1 --edition=2018 /home/ubuntu/.cargo/registry/src/github.com-1ecc6299db9ec823/libsecp256k1-0.6.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="hmac"' --cfg 'feature="hmac-drbg"' --cfg 'feature="sha2"' --cfg 'feature="static-context"' --cfg 'feature="std"' --cfg 'feature="typenum"' -C metadata=ff75ffe663998c68 -C extra-filename=-ff75ffe663998c68 --out-dir /home/ubuntu/solana/target/debug/deps -L dependency=/home/ubuntu/solana/target/debug/deps --extern arrayref=/home/ubuntu/solana/target/debug/deps/libarrayref-1170f8c828ab8d28.rmeta --extern base64=/home/ubuntu/solana/target/debug/deps/libbase64-3a8d5a57fd8274f7.rmeta --extern digest=/home/ubuntu/solana/target/debug/deps/libdigest-7c04696e4c42676b.rmeta --extern hmac_drbg=/home/ubuntu/solana/target/debug/deps/libhmac_drbg-4c12dff52eca0361.rmeta --extern libsecp256k1_core=/home/ubuntu/solana/target/debug/deps/liblibsecp256k1_core-5f3c6c6031e9b3bd.rmeta --extern rand=/home/ubuntu/solana/target/debug/deps/librand-df7d32eff7424b90.rmeta --extern serde=/home/ubuntu/solana/target/debug/deps/libserde-d9f9ddfe27b2d698.rmeta --extern sha2=/home/ubuntu/solana/target/debug/deps/libsha2-6bbaa12590c3611b.rmeta --extern typenum=/home/ubuntu/solana/target/debug/deps/libtypenum-17020373090ddbe4.rmeta --cap-lints allow (signal: 9, SIGKILL: kill) warning: build failed, waiting for other jobs to finish... {"message":"environment variable OUT_DIR not defined","code":null,"level":"error","spans":[{"file_name":"/home/ubuntu/.cargo/registry/src/github.com-1ecc6299db9ec823/libsecp256k1-0.6.0/src/lib.rs","byte_start":1716,"byte_end":1731,"line_start":56,"line_end":56,"column_start":59,"column_end":74,"is_primary":true,"text":[{"text":" unsafe { ECMultContext::new_from_raw(include!(concat!(env!("OUT_DIR"), "/const.rs"))) };","highlight_start":59,"highlight_end":74}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/home/ubuntu/.cargo/registry/src/github.com-1ecc6299db9ec823/libsecp256k1-0.6.0/src/lib.rs","byte_start":1716,"byte_end":1731,"line_start":56,"line_end":56,"column_start":59,"column_end":74,"is_primary":false,"text":[{"text":" unsafe { ECMultContext::new_from_raw(include!(concat!(env!("OUT_DIR"), "/const.rs"))) };","highlight_start":59,"highlight_end":74}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"env!","def_site_span":{"file_name":"/rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/macros/mod.rs","byte_start":30584,"byte_end":30747,"line_start":887,"line_end":890,"column_start":5,"column_end":6,"is_primary":false,"text":[],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: environment variable OUT_DIR not defined\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0m/home/ubuntu/.cargo/registry/src/github.com-1ecc6299db9ec823/libsecp256k1-0.6.0/src/lib.rs:56:59\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m56\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| ...\u001b[0m\u001b[0m_from_raw(include!(concat!(env!("OUT_DIR"), "/const.rs"))) };\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^^^^^^^^^^^^\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: this error originates in the macro env (in Nightly builds, run with -Z macro-backtrace for more info)\u001b[0m\n\n"} {"message":"environment variable OUT_DIR not defined","code":null,"level":"error","spans":[{"file_name":"/home/ubuntu/.cargo/registry/src/github.com-1ecc6299db9ec823/libsecp256k1-0.6.0/src/lib.rs","byte_start":2029,"byte_end":2044,"line_start":62,"line_end":62,"column_start":62,"column_end":77,"is_primary":true,"text":[{"text":" unsafe { ECMultGenContext::new_from_raw(include!(concat!(env!("OUT_DIR"), "/const_gen.rs"))) };","highlight_start":62,"highlight_end":77}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/home/ubuntu/.cargo/registry/src/github.com-1ecc6299db9ec823/libsecp256k1-0.6.0/src/lib.rs","byte_start":2029,"byte_end":2044,"line_start":62,"line_end":62,"column_start":62,"column_end":77,"is_primary":false,"text":[{"text":" unsafe { ECMultGenContext::new_from_raw(include!(concat!(env!("OUT_DIR"), "/const_gen.rs"))) };","highlight_start":62,"highlight_end":77}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"env!","def_site_span":{"file_name":"/rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/macros/mod.rs","byte_start":30584,"byte_end":30747,"line_start":887,"line_end":890,"column_start":5,"column_end":6,"is_primary":false,"text":[],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: environment variable OUT_DIR not defined\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0m/home/ubuntu/.cargo/registry/src/github.com-1ecc6299db9ec823/libsecp256k1-0.6.0/src/lib.rs:62:62\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m62\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| ...\u001b[0m\u001b[0m_from_raw(include!(concat!(env!("OUT_DIR"), "/const_gen.rs"))) };\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^^^^^^^^^^^^\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: this error originates in the macro env (in Nightly builds, run with -Z macro-backtrace for more info)\u001b[0m\n\n"} {"artifact":"/home/ubuntu/solana/target/debug/deps/libsecp256k1-ff75ffe663998c68.d","emit":"dep-info"} {"message":"aborting due to 2 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: aborting due to 2 previous errors\u001b[0m\n\n"}