- May 03, 2021
-
-
Peter Goodspeed-Niklaus authored
* Refactor election solution trimming for efficiency The previous version always trimmed the `CompactOf<T>` instance, which was intrinsically inefficient: that's a packed data structure, which is naturally expensive to edit. It's much easier to edit the unpacked data structures: the `voters` and `assignments` lists. * rework length-trim tests to work with the new interface Test suite now compiles. Tests still don't pass because the macro generating the compact structure still generates `unimplemented!()` for the actual `compact_length_of` implementation. * simplify * add a fuzzer which can validate `Compact::encoded_size_for` The `Compact` solution type is generated distinctly for each runtime, and has both three type parameters and a built-in limit to the number of candidates that each voter can vote for. Finally, they have an optional `#[compact]` attribute which changes the encoding behavior. The assignment truncation algorithm we're using depends on the ability to efficiently and accurately determine how much space a `Compact` solution will take once encoded. Together, these two facts imply that simple unit tests are not sufficient to validate the behavior of `Compact::encoded_size_for`. This commit adds such a fuzzer. It is designed such that it is possible to add a new fuzzer to the family by simply adjusting the `generate_solution_type` macro invocation as desired, and making a few minor documentation edits. Of course, the fuzzer still fails for now: the generated implementation for `encoded_size_for` is still `unimplemented!()`. However, once the macro is updated appropriately, this fuzzer family should allow us to gain confidence in the correctness of the generated code. * Revert "add a fuzzer which can validate `Compact::encoded_size_for`" This reverts commit 916038790887e64217c6a46e9a6d281386762bfb. The design of `Compact::encoded_size_for` is flawed. When `#[compact]` mode is enabled, every integer in the dataset is encoded using run- length encoding. This means that it is impossible to compute the final length faster than actually encoding the data structure, because the encoded length of every field varies with the actual value stored. Given that we won't be adding that method to the trait, we won't be needing a fuzzer to validate its performance. * revert changes to `trait CompactSolution` If `CompactSolution::encoded_size_for` can't be implemented in the way that we wanted, there's no point in adding it. * WIP: restructure trim_assignments_length by actually encoding This is not as efficient as what we'd hoped for, but it should still be better than what it's replacing. Overall efficiency of `fn trim_assignments_length` is now `O(edges * lg assignments.len())`. * fix compiler errors * don't sort voters, just assignments Sorting the `voters` list causes lots of problems; an invariant that we need to maintain is that an index into the voters list has a stable meaning. Luckily, it turns out that there is no need for the assignments list to correspond to the voters list. That isn't an invariant, though previously I'd thought that it was. This simplifies things; we can just leave the voters list alone, and sort the assignments list the way that is convenient. * WIP: add `IndexAssignment` type to speed up repeatedly creating `Compact` Next up: `impl<'a, T> From<&'a [IndexAssignmentOf<T>]> for Compact`, in the proc-macro which makes `Compact`. Should be a pretty straightforward adaptation of `from_assignment`. * Add IndexAssignment and conversion method to CompactSolution This involves a bit of duplication of types from `election-provider-multi-phase`; we'll clean those up shortly. I'm not entirely happy that we had to add a `from_index_assignments` method to `CompactSolution`, but we couldn't define `trait CompactSolution: TryFrom<&'a [Self::IndexAssignment]` because that made trait lookup recursive, and I didn't want to propagate `CompactSolutionOf<T> + TryFrom<&[IndexAssignmentOf<T>]>` everywhere that compact solutions are specified. * use `CompactSolution::from_index_assignment` and clean up dead code * get rid of `from_index_assignments` in favor of `TryFrom` * cause `pallet-election-provider-multi-phase` tests to compile successfully Mostly that's just updating the various test functions to keep track of refactorings elsewhere, though in a few places we needed to refactor some test-only helpers as well. * fix infinite binary search loop Turns out that moving `low` and `high` into an averager function is a bad idea, because the averager gets copies of those values, which of course are never updated. Can't use mutable references, because we want to read them elsewhere in the code. Just compute the average directly; life is better that way. * fix a test failure * fix the rest of test failures * remove unguarded subtraction * fix npos-elections tests compilation * ensure we use sp_std::vec::Vec in assignments * add IndexAssignmentOf to sp_npos_elections * move miner types to `unsigned` * use stable sort * rewrap some long comments * use existing cache instead of building a dedicated stake map * generalize the TryFrom bound on CompactSolution * undo adding sp-core dependency * consume assignments to produce index_assignments * Add a test of Assignment -> IndexAssignment -> Compact * fix `IndexAssignmentOf` doc * move compact test from sp-npos-elections-compact to sp-npos-elections This means that we can put the mocking parts of that into a proper mock package, put the test into a test package among other tests. Having the mocking parts in a mock package enables us to create a benchmark (which is treated as a separate crate) import them. * rename assignments -> sorted_assignments * sort after reducing to avoid potential re-sort issues * add runtime benchmark, fix critical binary search error "Why don't you add a benchmark?", he said. "It'll be good practice, and can help demonstrate that this isn't blowing up the runtime." He was absolutely right. The biggest discovery is that adding a parametric benchmark means that you get a bunch of new test cases, for free. This is excellent, because those test cases uncovered a binary search bug. Fixing that simplified that part of the code nicely. The other nice thing you get from a parametric benchmark is data about what each parameter does. In this case, `f` is the size factor: what percent of the votes (by size) should be removed. 0 means that we should keep everything, 95 means that we should trim down to 5% of original size or less. ``` Median Slopes Analysis ======== -- Extrinsic Time -- Model: Time ~= 3846 + v 0.015 + t 0 + a 0.192 + d 0 + f 0 µs Min Squares Analysis ======== -- Extrinsic Time -- Data points distribution: v t a d f mean µs sigma µs % <snip> 6000 1600 3000 800 0 4385 75.87 1.7% 6000 1600 3000 800 9 4089 46.28 1.1% 6000 1600 3000 800 18 3793 36.45 0.9% 6000 1600 3000 800 27 3365 41.13 1.2% 6000 1600 3000 800 36 3096 7.498 0.2% 6000 1600 3000 800 45 2774 17.96 0.6% 6000 1600 3000 800 54 2057 37.94 1.8% 6000 1600 3000 800 63 1885 2.515 0.1% 6000 1600 3000 800 72 1591 3.203 0.2% 6000 1600 3000 800 81 1219 25.72 2.1% 6000 1600 3000 800 90 859 5.295 0.6% 6000 1600 3000 800 95 684.6 2.969 0.4% Quality and confidence: param error v 0.008 t 0.029 a 0.008 d 0.044 f 0.185 Model: Time ~= 3957 + v 0.009 + t 0 + a 0.185 + d 0 + f 0 µs ``` What's nice about this is the clear negative correlation between amount removed and total time. The more we remove, the less total time things take.
-
ferrell-code authored
* first commit * get to compile * fix deprecated grandpa * formatting * module to pallet * add authorship pallet to mocks * Fix upgrade of storage. Co-authored-by: Xiliang Chen <[email protected]> * trigger CI * put back doc Co-authored-by: Guillaume Thiolliere <[email protected]> Co-authored-by: Xiliang Chen <[email protected]>
-
- May 02, 2021
-
-
Gavin Wood authored
-
- Apr 28, 2021
-
-
Gavin Wood authored
* Remove unneeded `Ord` bound from All * Fixes * Contains supports tuples
-
Erasmus Hagen authored
Link was a dead-end
-
- Apr 27, 2021
-
-
Gavin Wood authored
* Introduce macro for building Contains impl based on a match * Fixes
-
- Apr 26, 2021
-
-
Shawn Tabrizi authored
* bounded treasury approvals * update benchmarks * update configs * cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_treasury --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/treasury/src/weights.rs --template=./.maintain/frame-weight-template.hbs * fix weight param Co-authored-by: Parity Benchmarking Bot <[email protected]>
-
- Apr 23, 2021
-
-
François Garillot authored
* Simplify some Option / Result / ? operator patterns When those match a combinator exactly. Tool-aided by [comby-rust](https://github.com/huitseeker/comby-rust). * adjust after review * adjust post-review
-
Kian Paimani authored
* All done * Fix benchmarks * Apply suggestions from code review Co-authored-by: Guillaume Thiolliere <[email protected]> * Fix metadata. * Fix build * Add migrations * Fix * Update frame/elections-phragmen/src/migrations/v4.rs * Better migeation test * More test * Fix warn * Update frame/elections-phragmen/src/lib.rs Co-authored-by: Guillaume Thiolliere <[email protected]> * Fix test * early exit * Fix * Fix build Co-authored-by: Guillaume Thiolliere <[email protected]>
-
- Apr 22, 2021
-
-
Xiliang Chen authored
* impl Zero and One for fixed point numbers * update librocksdb-sys to support M1 * fix build * trigger CI
-
Alexander Theißen authored
-
- Apr 19, 2021
-
-
Alexander Theißen authored
* Update parity-wasm * Cleanup Cargo.toml files - Sort dependencies - Remove minor and fix version where they are not necessary * Update pretty_assertions * Update rand
-
thiolliere authored
* generate accessor to PalletInfo information on pallet placeholder * remove unused * use trait, and add tests * less verbose doc * add PalletInfoAccess to prelude for ease usage
-
- Apr 18, 2021
-
-
Kian Paimani authored
* Add benchmakrs for membership * Update frame/membership/src/lib.rs Co-authored-by: Guillaume Thiolliere <[email protected]> * Make it all work * Add mock weights * Update frame/membership/src/lib.rs * Update frame/membership/src/lib.rs Co-authored-by: Guillaume Thiolliere <[email protected]> * cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_membership --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/membership/src/weights.rs --template=./.maintain/frame-weight-template.hbs * cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_membership --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/membership/src/weights.rs --template=./.maintain/frame-weight-template.hbs Co-authored-by: Guillaume Thiolliere <[email protected]> Co-authored-by: Parity Benchmarking Bot <[email protected]>
-
ferrell-code authored
* migrate to new macro * formatting * Apply suggestions from code review * Update frame/authority-discovery/src/lib.rs Co-authored-by: Guillaume Thiolliere <[email protected]>
-
- Apr 17, 2021
-
-
thiolliere authored
-
- Apr 16, 2021
-
-
Bastian Köcher authored
* Remove `serde` requirement from FRAME macros Currently there is some implicit requirement on `serde` being present in the `Cargo.toml` of a pallet when `GenesisConfig` is used. This pr removes this requirement by using the serde attribute `serde(crate = "..")`. * build a unique reexport of serde in impl_opaque_keys, by abusing paste doc concatenation * Optimize Co-authored-by: thiolliere <[email protected]>
-
Daniel Olano authored
* Make pallet Assets instantiable * use instantiable benchmarks Co-authored-by: Shawn Tabrizi <[email protected]>
-
Kian Paimani authored
* prototype for shawn * Clean and document it * Add more docs * Move imports * Some changes for easier compat. * revert exmaple pallet * rename * BoundedVec for AccountLocks (#8580) * Example with balances * Fix tests * Make it indexable * fix * Fix tests * fix test * Fix collective as well * Fix test * Update frame/support/src/storage/mod.rs Co-authored-by: Peter Goodspeed-Niklaus <[email protected]> * Repot and add for value * Add for map and double map * Final touches. * Update frame/support/src/storage/bounded_vec.rs Co-authored-by: Guillaume Thiolliere <[email protected]> * Add a few more tests * Add import Co-authored-by: Peter Goodspeed-Niklaus <[email protected]> Co-authored-by: Guillaume Thiolliere <[email protected]>
-
- Apr 13, 2021
-
-
Peter Goodspeed-Niklaus authored
Co-authored-by: Guillaume Thiolliere <[email protected]> Co-authored-by: Kian Paimani <[email protected]>
-
Xiliang Chen authored
* expose set_timestamp for runtime benchmarks * Update frame/timestamp/src/lib.rs Co-authored-by: Guillaume Thiolliere <[email protected]> Co-authored-by: Guillaume Thiolliere <[email protected]>
-
Alexander Theißen authored
* contracts: Add RPC that allows instantiating of a contract * Encode `debug_message` as bytes because usage of `String` is forbidden * Remove erroneous derive attribute * Fix rpc tests for new `debug_message` encoding * Fix typo Co-authored-by: Andrew Jones <[email protected]> Co-authored-by: Andrew Jones <[email protected]>
-
Falco Hirschenberger authored
* Change is_err() asserts in tests to assert_noop to check state consistency fixes #8545 * Update frame/transaction-payment/src/lib.rs Co-authored-by: Kian Paimani <[email protected]> * Update frame/contracts/src/exec.rs Co-authored-by: Shawn Tabrizi <[email protected]> * Update frame/democracy/src/benchmarking.rs Co-authored-by: Shawn Tabrizi <[email protected]> * Update frame/transaction-payment/src/lib.rs Co-authored-by: Shawn Tabrizi <[email protected]> * Don't assert no-changing state. see: https://github.com/paritytech/substrate/pull/8587#issuecomment-817137906 * fix expected error * Fix non-extrinsic-call asserts Co-authored-by: Kian Paimani <[email protected]> Co-authored-by: Shawn Tabrizi <[email protected]>
-
Chris D'Costa authored
-
thiolliere authored
* impl * fix tests * impl in execute_block * fix tests * add a test in frame-executive * fix some panic warning * use trait to get call from extrinsic * remove unused * fix test * fix testing * fix tests * return index of extrinsic on error * fix test * Update primitives/inherents/src/lib.rs Co-authored-by: Kian Paimani <[email protected]> * address comments rename trait, and refactor * refactor + doc improvment * fix tests Co-authored-by: Kian Paimani <[email protected]>
-
- Apr 12, 2021
-
-
Bastian Köcher authored
-
Keith Yeung authored
-
Bastian Köcher authored
Make it work with different kinds of parameter types when `static` is one of them.
-
- Apr 10, 2021
-
-
Gavin Wood authored
* IsInVec * Purify `Contains`, introduce SortedMembers
-
Shawn Tabrizi authored
* write benchmark for transfer increasing users * cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_balances --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/balances/src/weights.rs --template=./.maintain/frame-weight-template.hbs Co-authored-by: Parity Benchmarking Bot <[email protected]>
-
- Apr 09, 2021
-
-
Kian Paimani authored
-
Gavin Wood authored
* Backing/GetBacking: Abstraction over pluralistic origins for XCM. * Update frame/support/src/traits/misc.rs Co-authored-by: Kian Paimani <[email protected]> * Update frame/support/src/traits/misc.rs Co-authored-by: Kian Paimani <[email protected]> Co-authored-by: Kian Paimani <[email protected]>
-
Xavier Lau authored
* `ModuleId` to `PalletId` - part of #8372 * fix doc * move `PalletId` to `frame-support` * fix compile * fix tests * `ModuleId` to `PalletId` * subcommand `moduleid` to `palletid`
-
- Apr 08, 2021
-
-
Gavin Wood authored
* Allow lossless matching for Origin Without these changes, it's difficult/impossible to not lose any filters when making fine-grained matches against origin. * whilespace * Apply suggestions from code review Co-authored-by: Kian Paimani <[email protected]> Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: Kian Paimani <[email protected]> Co-authored-by: Bastian Köcher <[email protected]>
-
Kian Paimani authored
* Add DefaultNoBound * Add tests * Fix
-
Shawn Tabrizi authored
* Added a function to estimate proof size for benchmarking * integrate proof_size into benchmarking pipeline * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <[email protected]> * fix tests * one more test * Update bench.rs * Update utils/frame/benchmarking-cli/src/writer.rs Co-authored-by: Alexander Popiak <[email protected]> * Update utils/frame/benchmarking-cli/src/command.rs Co-authored-by: Kian Paimani <[email protected]> Co-authored-by: arkpar <[email protected]> Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: Alexander Popiak <[email protected]> Co-authored-by: Kian Paimani <[email protected]>
-
- Apr 07, 2021
-
-
Falco Hirschenberger authored
* Add more asserts and debug_asserts fixing #8106 * Remove assignments * convert debug_assert to runtime assert
-
Shawn Tabrizi authored
* Add an index to the Instance trait * Update frame/support/procedural/src/storage/instance_trait.rs
-
- Apr 06, 2021
-
-
Gavin Wood authored
* Bump codec. * Bump codec-derive * Remove FullCodec bound on Call
-
Gavin Wood authored
* Fix account ref-counting in session. * Avoid needless check * fix compile * put back in check and conversion * Fix test to actually catch this error Co-authored-by: Shawn Tabrizi <[email protected]>
-