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

Cleanup String::from_utf8 usage in the pallet benchmarking #389

Closed
ggwpez opened this issue Jul 25, 2022 · 8 comments · Fixed by #3446
Closed

Cleanup String::from_utf8 usage in the pallet benchmarking #389

ggwpez opened this issue Jul 25, 2022 · 8 comments · Fixed by #3446
Assignees
Labels
C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. D0-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder. I4-refactor Code needs refactoring.

Comments

@ggwpez
Copy link
Member

ggwpez commented Jul 25, 2022

👉 Good issue for newcomers (please dont pick up when you already have experience).

The state machine that is used in the benchmark pallet command returns a [u8] instead of a string.
This slice is then stored and converted to a string every time its needed somewhere.
It would be nice to instead directly convert it and then store the string. This would get rid of a many String::from_utf8(…).expect("Encoded from String; qed").

@sudipghimire533
Copy link

I can take on this guys if you are ok with it @ggwpez

@ggwpez
Copy link
Member Author

ggwpez commented Jul 25, 2022

Yes thats good, thanks @sudipghimire533

@sudipghimire533
Copy link

@ggwpez Looks like I am not sure which part are we referring. Can you please mention a example where the change should be brought. Thank you :)

@ggwpez
Copy link
Member Author

ggwpez commented Jul 26, 2022

You can start by searching for String::from_utf8 in the utils/frame/benchmarking-cli folder.
Once you see where its used, you can start to put it into a String variable so that the from_utf8 can be removed, should be easy.

@sudipghimire533
Copy link

Ahh ok PR 11908 took longer than expected. I'll try if I can give time. Thanks anyway :)

@juangirini juangirini transferred this issue from paritytech/substrate Aug 24, 2023
@the-right-joyce the-right-joyce added I4-refactor Code needs refactoring. C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. and removed I7-refactor labels Aug 25, 2023
@ggwpez ggwpez added the D0-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder. label Feb 4, 2024
@philoniare
Copy link
Contributor

@ggwpez can I take this on?

@ggwpez
Copy link
Member Author

ggwpez commented Feb 22, 2024

Yes! Note that we cannot entirely use String, since it get passed through the WASM-Host barrier and that only allows Vec<u8> so it can only be converted after being in the std code.

@philoniare
Copy link
Contributor

philoniare commented Feb 22, 2024

Yes! Note that we cannot entirely use String, since it get passed through the WASM-Host barrier and that only allows Vec<u8> so it can only be converted after being in the std code.

Got it, appreciate the tip, will keep it in mind

github-merge-queue bot pushed a commit that referenced this issue Feb 26, 2024
# Description

*Refactors `String::from_utf8` usage in the pallet benchmarking

Fixes #389

---------

Co-authored-by: command-bot <>
@github-project-automation github-project-automation bot moved this from Backlog to Done in Benchmarking and Weights Feb 26, 2024
bgallois pushed a commit to duniter/duniter-polkadot-sdk that referenced this issue Mar 25, 2024
# Description

*Refactors `String::from_utf8` usage in the pallet benchmarking

Fixes paritytech#389

---------

Co-authored-by: command-bot <>
jonathanudd pushed a commit to jonathanudd/polkadot-sdk that referenced this issue Apr 10, 2024
* Implement public helpers for querying header info

* Update `best_header` when importing headers

* Add BestHeader to GenesisConfig

* Define extra types for Millau primitives

* Start implementing runtime APIs in Millau runtime

* Add helper for getting headers which require a justification

* Add runtime API for getting headers requiring a justification

* Reword `expect()` proof for valid authority sets

* Fix typo

* Clean up Hasher comment

* Add the Call Dispatch Pallet back to the Millau runtime

* Use types from Rialto in bridge pallet config

* Use the Rialto runtime APIS in the Millau runtime

* Include Millau bridge instance in Rialto runtime

* Add missing doc comment

* Use one storage function for setting and clearing `RequiresJustification`

* Remove TODO comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. D0-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder. I4-refactor Code needs refactoring.
Projects
Development

Successfully merging a pull request may close this issue.

4 participants