Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Fixed extrinsic encoding #794

Merged
merged 4 commits into from
Sep 25, 2018
Merged

Fixed extrinsic encoding #794

merged 4 commits into from
Sep 25, 2018

Conversation

arkpar
Copy link
Member

@arkpar arkpar commented Sep 24, 2018

No description provided.

@arkpar arkpar added the A0-please_review Pull request needs code review. label Sep 24, 2018
// to use this).
let _length_do_not_remove_me_see_above: u32 = Decode::decode(input)?;
let _length_do_not_remove_me_see_above: Vec<()> = Decode::decode(input)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

We are avoiding Compact<u32> here, right?

If so, the problem with Vec<()> is that the generated code is less optimal. It will actually try to check for capacity overflow, increase length and other things to keep semantics of Vec. Consider changing it to Compact.

Copy link
Member Author

Choose a reason for hiding this comment

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

It does not matter as long as it does not allocate. I'd prefer not to rely on internal details of how Vec is encoded.

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed, it shouldn't allocate, but still will iterate n times.

I'd prefer not to rely on internal details of how Vec is encoded.

Fair enough. The fact that it was different has lead to this issue in the first place. However, maybe the test that tests equivalence for some values would be enough?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've checked that Vec<()> does not do any capacity calculations. Capacity is always reported as usize::max_value() and resize function is just 6 ASM instructions in debug build, 1 inlined instruction in release build.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, interesting. That's actually makes sense, since it's ZST.

My observation was based on checking the wasm build, I wonder why it is generated this way.

@pepyakin pepyakin added A8-looksgood and removed A0-please_review Pull request needs code review. labels Sep 24, 2018
// Vec<u8>.
let mut length: Vec<()> = Vec::new();
length.resize(v.len(), ());
length.using_encoded(|s| { v.splice(0..0, s.iter().cloned()); });
Copy link
Member

Choose a reason for hiding this comment

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

will always need to do a memmove. we could skip this in most cases by a well chosen space reservation as before.

@arkpar arkpar added A3-in_progress Pull request is in progress. No review needed at this stage. and removed A7-looksgoodcantmerge labels Sep 25, 2018
@arkpar arkpar added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Sep 25, 2018
@arkpar
Copy link
Member Author

arkpar commented Sep 25, 2018

Added a heuristic to reserve the prefix.

@gavofyork gavofyork added A8-looksgood and removed A0-please_review Pull request needs code review. labels Sep 25, 2018
@gavofyork gavofyork merged commit a5077f3 into master Sep 25, 2018
@gavofyork gavofyork deleted the a-ext-encode-fix branch September 25, 2018 16:01
liuchengxu pushed a commit to chainx-org/substrate that referenced this pull request Aug 23, 2021
* Add LastRenominationOf

Close paritytech#692

* Fix renominate tests

* Build wasm
liuchengxu added a commit to chainx-org/substrate that referenced this pull request Aug 23, 2021
* Introduce Delta

* Add VoteWeightBase

* Upper bound of intention (paritytech#796)

* Add UpperBoundFactor

Close paritytech#672

* Check if the intention is nominating itself and add tests

* Add set_upper_bound_factor and build wasm

* Add LastRenominationOf (paritytech#794)

* Add LastRenominationOf

Close paritytech#692

* Fix renominate tests

* Build wasm

* genesis bitcoin (paritytech#799)

genesis runtime wasm

notice, do not copy wasm file into cli/src for develop!

* Add MaxUnbondEntriesPerIntention (paritytech#800)

* Add MaxUnbondEntriesPerIntention

Close paritytech#681

* Add test

* Nits

* Nit

* Pass tests

* Replace settle_amount() with settle_and_set_amount()

* Nit

* Build wasm

* Rename set_new_state to set_state

* Rebuild wasm
helin6 pushed a commit to boolnetwork/substrate that referenced this pull request Jul 25, 2023
* Add _at and _with methods to OnlineClient to allow for more instantiation options

* tweak warnings

* move a confusing comment

* expose ability to set metadata and such in OnlineClient, but remove most _at methods
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants