Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable use of global secp256k1 context #1123

Merged
merged 5 commits into from
Feb 10, 2022
Merged

Conversation

davxy
Copy link
Contributor

@davxy davxy commented Feb 7, 2022

Context creation is expensive.

Use the preallocated context that ships with the library.

Follows from the work done for this paritytech/substrate#10798

Context creation is expensive.

Use the preallocated context that ships with the library.
@paritytech-cicd-pr
Copy link

paritytech-cicd-pr commented Feb 7, 2022

🦑 📈 ink! Example Contracts ‒ Changes Report 📉 🦑

These are the results when building the examples/* contracts from this branch with cargo-contract 0.17.0-1d1dc59 and comparing them to ink! master:

Δ Optimized Size Δ Used Gas Total Optimized Size Total Used Gas
accumulator 1.44 K
adder 2.94 K
contract-terminate 1.31 K 215_704
contract-transfer +0.57 K 8.55 K 15_704
delegator 7.63 K 51_343
dns 10.20 K 47_112
erc1155 +0.82 K 28.32 K 94_224
erc20 9.80 K 47_112
erc721 13.70 K 125_632
flipper 1.76 K 15_704
incrementer 1.64 K 15_704
multisig -0.02 K 26.76 K 103_580
proxy +0.06 K +61 3.87 K 32_304
rand-extension 5.12 K 15_704
subber 2.96 K
trait-erc20 10.10 K 47_112
trait-flipper 1.53 K 15_704
trait-incrementer 1.62 K 31_408

Link to the run | Last update: Thu Feb 10 18:44:07 CET 2022

@codecov-commenter
Copy link

codecov-commenter commented Feb 7, 2022

Codecov Report

Merging #1123 (f34b28d) into master (1188ee7) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1123      +/-   ##
==========================================
- Coverage   78.80%   78.78%   -0.02%     
==========================================
  Files         252      252              
  Lines        9397     9394       -3     
==========================================
- Hits         7405     7401       -4     
- Misses       1992     1993       +1     
Impacted Files Coverage Δ
crates/engine/src/tests.rs 100.00% <ø> (ø)
crates/engine/src/ext.rs 72.22% <100.00%> (-0.20%) ⬇️
...tes/env/src/engine/experimental_off_chain/impls.rs 53.70% <100.00%> (-0.43%) ⬇️
crates/env/src/engine/off_chain/impls.rs 41.88% <100.00%> (-0.50%) ⬇️
...ates/storage/src/collections/hashmap/fuzz_tests.rs 94.68% <0.00%> (-1.07%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1188ee7...f34b28d. Read the comment docs.

@xgreenx
Copy link
Collaborator

xgreenx commented Feb 7, 2022

ink! doesn't use secp256k1 to recover, generate keys. So it doesn't use the context. Usage of the context will increase the size of the contracts. It is why that function was moved to contract-pallet.

Maybe I'm not right and it doesn't affect the size of the contract, could you check it, please?=)

@davxy
Copy link
Contributor Author

davxy commented Feb 7, 2022

ink! doesn't use secp256k1 to recover, generate keys. So it doesn't use the context. Usage of the context will increase the size of the contracts. It is why that function was moved to contract-pallet.

Maybe I'm not right and it doesn't affect the size of the contract, could you check it, please?=)

@xgreenx Ink! has already replaced libsecp256k1 with secp256k1 here #1052

If you check the changed files, this PR only introduces the usage of the global secp256k1 feature.

But maybe that is not what you mean and I misinterpreted your comment :-)

@xgreenx
Copy link
Collaborator

xgreenx commented Feb 7, 2022

Ohh, okay, you only enabled that feature for tests. You didn't touch the code related to contracts.

Copy link
Contributor

@HCastano HCastano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine, just one thing to check related to std features

crates/env/Cargo.toml Outdated Show resolved Hide resolved
crates/engine/Cargo.toml Outdated Show resolved Hide resolved
* `global-context` feature depends on `std`
* Its usage scope was already limited to `std` environment
Copy link
Contributor

@HCastano HCastano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why there are contract size changes. I checked PR out and built the contracts locally and they're smaller than what the waterfall reports (and match master) 🤷‍♂️

Anyways, thanks!

@HCastano HCastano merged commit 88b12d6 into master Feb 10, 2022
@HCastano HCastano deleted the davxy-secp256-static-context branch February 10, 2022 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants