* pallet-contracts: Fix seal_restore_to to output proper module errors
Those errors where part of the decl_error for some time but where
never actually returned. This allows proper debugging of failed
restorations. Previously, any error did return the misleading
`ContractTrapped`.
* Bind UncheckedFrom<T::Hash> + AsRef<[u8]> everywhere
This allows us to make assumptions about the AccoutId
that are necessary for testing and in order to benchmark
the module properly.
This also groups free standing functions into inherent functions
in order to minimize the places where the new bounds need to
be specified.
* Rework contract address determination
* Do not allow override by runtime author
* Instantiate gained a new parameter "salt"
This change is done now in expecation of the upcoming code rent
which needs to change the instantiation dispatchable and
host function anyways.
The situation in where we have only something that is like CREATE2
makes it impossible for UIs to help the user to create an arbitrary
amount of instantiations from the same code.
With this change we have the same functionality as ethereum with
a CREATE and CREATE2 instantation semantic.
* Remove TrieIdGenerator
The new trait bounds allows us to remove this workaround
from the configuration trait.
* Remove default parameters for config trait
It should be solely the responsiblity to determine proper values for
these parameter. As a matter of fact most runtime weren't using these
values anyways.
* Fix tests for new account id type
Because of the new bounds on the trait tests can't get away by using
u64 as accound id. Replacing the 8 byte value by a 32 byte value
creates out quite a bit of code churn.
* Fix benchmarks
The benchmarks need adaption to the new instantiate semantics.
* Fix compile errors caused by adding new trait bounds
* Fix compile errors caused by renaming storage and rent functions
* Adapt host functions and dispatchables to the new salt
* Add tests for instantiate host functions (was not possible before)
* Add benchmark results
* Adapt to the new WeightInfo
The new benchmarks add a new parameter for salt "s" to the instantiate weights
that needs to be applied.
* Fix deploying_wasm_contract_should_work integration test
This test is adapted to use the new instantiate signature.
* Break overlong line
* Break more long lines
Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
* Build every wasm crate in its own project with wasm-builder
Building all wasm crates in one workspace was a nice idea, however it
just introduced problems:
1. We needed to prune old members, but this didn't worked for old git
deps.
2. We locked the whole wasm workspace while building one crate. This
could lead to infinitely locking the workspace on a crash.
Now we just build every crate in its own project, this means we will
build the dependencies multiple times. While building the dependencies
multiple times, we still decrease the build time by around 30 seconds
for Polkadot and Substrate because of the new parallelism ;)
* Remove the requirement on wasm-builder-runner
This removes the requirement on wasm-builder-runner by using the new
`build_dep` feature of cargo. We use nightly anyway and that enables us
to use this feature. This solves the problem of not mixing
build/proc-macro deps with normal deps. By doing this we get rid off
this complicated project structure and can depend directly on
`wasm-builder`. This also removes all the code from wasm-builder-runner
and mentions that it is deprecated.
* Copy the `Cargo.lock` to the correct folder
* Remove wasm-builder-runner
* Update docs
* Fix deterministic check
Modified-by: Bastian Köcher <git@kchr.de>
* Try to make the ui test happy
* Switch to `SKIP_WASM_BUILD`
* Rename `SKIP_WASM_BINARY` to the correct name...
* Update utils/wasm-builder/src/builder.rs
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
* Update utils/wasm-builder/src/builder.rs
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
* More extensible multiaddress format
* update name
* Don't depend on indices to define multiaddress type
* Use MultiAddress in Node Template too!
* reduce traits, fix build
* support multiple `StaticLookup`
* bump tx version
* feedback
* pallet_contracts: Inline benchmark helper that is only used once
* Move all max_* Schedule items into a new struct
* Limit the number of globals a module can declare
* The current limits are too high for wasmi to even execute
* Limit the amount of parameters any wasm function is allowed to have
* Limit the size the BrTable's immediate value
* Add instruction benchmarks
* Add new benchmarks to the schedule and make use of it
* Add Benchmark Results generated by the bench bot
* Add proc macro that implements `Debug` for `Schedule`
* Add missing imports necessary for no_std build
* Make the WeightDebug macro available for no_std
In this case a dummy implementation is derived in order to not
blow up the code size akin to the RuntimeDebug macro.
* Rework instr_memory_grow benchmark to use only the maximum amount of pages allowed
* Add maximum amount of memory when benching (seal_)call/instantiate
* cargo run --release --features runtime-benchmarks --manifest-path bin/node/cli/Cargo.toml -- benchmark --chain dev --steps 50 --repeat 20 --extrinsic * --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output ./bin/node/runtime/src/weights --header ./HEADER --pallet pallet_contracts
* Added utility benchmark that allows pretty printing of the real schedule
* review: Add missing header to the proc-macro lib.rs
* review: Clarify why #[allow(dead_code)] attribute is there
* review: Fix pwasm-utils line
* review: Fixup rand usage
* review: Fix typo
* review: Imported -> Exported
* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_contracts --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/contracts/src/weights.rs --template=./.maintain/frame-weight-template.hbs
* contracts: Adapt to new weight structure
* contracts: Fixup runtime WeightInfo
* contracts: Remove unneeded fullpath of WeightInfo type
* Apply suggestions from code review
Co-authored-by: Andrew Jones <ascjones@gmail.com>
* Fix typo in schedule.rs
Co-authored-by: Andrew Jones <ascjones@gmail.com>
* Fix docs in schedule.rs
* Apply suggestions from code review
Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
* Don't publish proc-macro crate until 3.0.0 is ready
* Optimize imports for less repetition
* Break overlong line
Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
Co-authored-by: Andrew Jones <ascjones@gmail.com>
Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
* contracts: Make use of existing type aliases for runtime API types
* contracts: Refactor the contracts call runtime API
* review: Fix comment typo
Co-authored-by: Andrew Jones <ascjones@gmail.com>
* Update frame/contracts/common/src/lib.rs
Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
* Update frame/contracts/common/src/lib.rs
Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
* Update frame/contracts/common/src/lib.rs
Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
* Update frame/contracts/common/src/lib.rs
Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
* Update frame/contracts/common/src/lib.rs
Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
* Update lib.rs
* review: Group crate imports
Co-authored-by: Andrew Jones <ascjones@gmail.com>
Co-authored-by: Addie Wagenknecht <addie@nortd.com>
Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
* seal: Add capability to put uninstrumented code (for benchmarks)
Benchmarks should only measure the overhead of the API calls itself.
For that reason we want to run them without instrumentation.
* seal: Cap the the data length for deposited events
Data used in events has storage implications for archive nodes.
Those need to keep the events in storage forever. For that reason
we want to limit the amount of storage that can be used inside events.
* seal: Fix error reporting in the case out of bound sandbox access
* seal: Refactor existing benchmarks
* seal: Convert benchmark file to tabs
* seal: Add benchmarks for functions called by contracts
* seal: Create a default schedule from benchmark generated WeightInfo
* seal: Make use of WeightInfo in extrinsic weight annotations
* seal: Replace the old schedule by the benchmark generated one
* Review: Fix copy paste typo in schedule construction
* Review: Fix stale docs
* Fix whitespace errors
Co-authored-by: Sergei Shulepov <sergei@parity.io>
* Review: Use checked_div in order to be more defensive
* Review: Rename no_charge to already_charged
* Review: Whitelist caller of extrinsics
* Review: Remove trailing whitespace
* Review: Remove confusing "self::" syntax
* Review: Add docs for the benchmark prepration submodule
* Review: Move code generation functions to own module
* Review: Refactor and document benchmark helper functions
* Remove additional empty line
* Added missing comment on caller_funding
* Update frame/contracts/src/benchmarking/code.rs
Co-authored-by: Sergei Shulepov <sergei@parity.io>
* Fix missing sp_std::prelude import in code.rs
* cargo run --release --features runtime-benchmarks --manifest-path bin/node/cli/Cargo.toml -- benchmark --chain dev --steps 50 --repeat 20 --extrinsic * --execution=wasm --wasm-execution=compiled --output ./bin/node/runtime/src/weights --header ./HEADER --pallet pallet_contracts --heap-pages 4096
* Use weights from the benchmark machine for the substrate node
* Remove prefixes from Schedule members
* Data lengths in the WeightInfo Trait are specified in kilobytes
* Rename ApiWeights to HostFunctionWeights
Co-authored-by: Sergei Shulepov <sergei@parity.io>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
* Revamp npos-elections and implement phragmms
* Update primitives/npos-elections/src/phragmms.rs
* Fix build
* Some review grumbles
* Add some stuff for remote testing
* fix some of the grumbles.
* Add remote testing stuff.
* Cleanup
* fix docs
* Update primitives/arithmetic/src/rational.rs
Co-authored-by: Dan Forbes <dan@danforbes.dev>
* Small config change
* Better handling of approval_stake == 0
* Final touhces.
* Clean fuzzer a bit
* Clean fuzzer a bit
* Update primitives/npos-elections/src/balancing.rs
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
* Fix fuzzer.
* Better api for normalize
* Add noramlize_up
* A large number of small fixes.
* make it merge ready
* Fix warns
* bump
* Fix fuzzers a bit.
* Fix warns as well.
* Fix more tests.
Co-authored-by: Dan Forbes <dan@danforbes.dev>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
* Rename `ModuleToIndex` to `PalletRuntimeSetup`
Besides the renaming it also adds support getting the name of a pallet
as configured in the runtime.
* Rename it to `PalletInfo`
* Remove accidentally added files
* as multi threshold 1
* add `as_multi_approve_store` benchmark
* finish update
* final weights
* integrate into runtime
* whitelist accounts
* whitelisted caller weights
* clean up comments
* Get up to date `call_len`
* better implementation
* fix spacing
* spacing
* Update frame/multisig/src/benchmarking.rs
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
* update benchmarks
* add automated weights
* Update benchmarking.rs
* use underscores for file out
* update some weights
* more weights
* finish weights
* add basic verification to benchmarks
* patch benchmarks
* Update benchmarking.rs
* final weights
* update for new type
* add weightinfo to node
* collective: add DefaultVote trait
* Fix test and node compile
* Expose the whole prime_vote
* Add test for MoreThanMajorityThenPrimeDefaultVote
* Docs fix
* Add `--verify` flag to benchmark execution
* make it so `--verify` can be used for getting the actual benchmarks
* undo manual testing
* oops
* use benchmark config struct
* verify is default on, docs update
* remove clone
* improve formatting
* fix test
* bump impl for ci
* draft
* revert
* WIP
* all that remains is tests
* update Cargo.lock
* tests WIP
* WIP refactor node-template-runtime and node-runtime
* implments sc_cli::RuntimeAdapter for node_template_runtime::Runtime
* final draft
* fix update_config for subcommands
* proper AccountId decoding
* test-runtime tests
* revert
* move RuntimeAdapter to cli-utils
* use &'static str for TryFrom::<&'a str>::Error for Ss58AddressFormat
* tests
* add frame-system to sc-cli dev-dependencies
* add frame-system to sc-cli dev-dependencies
* fix ui test
* wip
* fixed inspect test
* bump impl version
* bump impl version, fixx spaces remove todos
* pallet-balances-cli, rustc for some reason cannot resolve pallet_balances_cli in node-cli 😩
* wip
* Subcommand::run takes &self
* can't believe i missed that 🤦🏾♂️
* bump wasm-bindgen for some reason
* adds key subcommand, rename generate-node-key to generate-node-id
* cargo update and crossed fingers 🤞🏽
* update ui test
* update more ui tests
* should be all good now
* revert subkey change
* revert subkey change
* adds frame-utilities-cli
* Apply suggestions from code review
Co-authored-by: Benjamin Kampmann <ben@gnunicorn.org>
* removes frame from sc-cli, fix license
* my editor and ci disagrees on line width
* bump spec version
* turn off default features for parity-scale-codec
* enable full_crypto feature for sp-core in cli-utils
* merge frame-utilities-cli with pallet-balances-cli
* remove full_crypto feature from sp_core in cli-utils
* bump Cargo.lock
* cli-utils -> frame-utils
* rename BlockNumber to GenericNumber, fix spaces
* fix spaces
* construct additional_signed manually
* sign test
* remove unused vars
* implement subkey with frame-utilities-cli and sc_cli
* fix moduleid test
* CI and clion disagree on line widths
* adds associated Params type to SignedExtensionProvider
* Apply suggestions from code review
Co-authored-by: Benjamin Kampmann <ben@gnunicorn.org>
* move some code around
* removes unneccesary generic params
* moves module_id back to frame_utilities_cli
* Apply suggestions from code review
Co-authored-by: Benjamin Kampmann <ben@gnunicorn.org>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
* remove print_ext
* remove MaybeDisplay from pallet_balances::Trait::Balance
* a lot of stuff tbh
* adds ExtrasParamsBuilder
* remove tests for ModuleIdCmd
* address comments from PR
* bump Cargo.lock
* manually insert key into keystore
* remove unnecessary SharedParams
* add validation to vanity pattern, remove unused arg
* remove SharedParams from Sign, Vanity, Verify
* remove SharedParams from ModuleIdCmd, remove expect from Verify, new line to Cargo.toml
* remove SharedParams from InsertCmd
* 🤦🏾♂️
* deleted prometheus.yml
* move a few things around
* fix vanity test
Co-authored-by: Benjamin Kampmann <ben@gnunicorn.org>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Benjamin Kampmann <ben@parity.io>
* democracy use of weightinfo
* fix some doc and benchs
* todo generate from parity machine
* factorize and add license
* use final weights
* add slightly more sensible default weight
* refactor
* rename benchmark to avoid confusion
* just make remove_other_vote benchmark being the worst case of the extrinsic
The transaction payment runtime api used its own extrinsic generic
parameter. This is wrong, because this resulted in using always the
native extrinsic. If there was a runtime upgrade that changed the
extrinsic in some way, it would result in the api breaking. The correct
way is to use the `Extrinsic` from the `Block` parameter. This is on the
node side the opaque extrinsic and on the runtime side the real extrinsic.
* Update balance benchmarks
* Update weight functions
* Remove user component
* make componentless
* Add support for `#[extra]` tag on benchmarks
* Update balances completely
* Apply suggestions from code review
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
* Fix some tests
* Maybe fix to test. Need approval from @tomusdrw this is okay
* Make test better
* keep weights conservative
* Update macro for merge master
* Add headers
* Apply suggestions from code review
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
* seal: Fix syntax that confuses rust-analyzer
* seal: Add benchmarks for Dispatchables
These are only the benchmarks for the dispatchables of
the pallet. Those are not listed in the Schedule because
we do not want to pull the Schedule from storage before
dispatching.
This OK because those costs are not related to actual contract
execution. Those costs (instruction costs, ext_* costs) will
be benchmarked seperatly and entered into the default Schedule.
* seal: Add a maximum code size
* Fix comments from review
* Removed SEED constant
* seal: Fail instantiate if new contract is below subsistence threshold
We need each contract that exists to be above the subsistence threshold
in order to keep up the guarantuee that we always leave a tombstone behind
with the exception of a contract that called `ext_terminate`.
* Fixup executor test
* Bump runtime