* Do not call `initialize_block` before any runtime api
Before this change we always called `initialize_block` before calling
into the runtime. There was already support with `skip_initialize` to skip
the initialization. Almost no runtime_api requires that
`initialize_block` is called before. Actually this only leads to higher
execution times most of the time, because all runtime modules are
initialized and this is especially expensive when the block contained a
runtime upgrade.
TLDR: Do not call `initialize_block` before calling a runtime api.
* Change `validate_transaction` interface
* Fix rpc test
* Fixes and comments
* Some docs
* Remove unused event_metadata variable
* Eliminate mod_name and use pallet names to name enum variants
* Rename field name `pallet` to `path`
* Use only the pallet name to generate variant names
* Use new naming scheme for Event enum in sudo pallet tests
* Use new naming scheme for Event enum in offences pallet tests
* Use new naming scheme for Event enum in contracts pallet tests
* Use new naming scheme for Event enum in collective pallet tests
* Use new naming scheme for Event enum in bounties pallet tests
* Use new naming scheme for Event enum in balances pallet tests
* Use new naming scheme for Event enum in assets pallet tests
* Use new naming scheme for Event enum in frame support tests
* Use new naming scheme for Event enum in tips pallet tests
* Use new naming scheme for Event enum in transaction payment pallet tests
* Use new naming scheme for GenesisConfig fields in example pallet tests
* Use new naming scheme for GenesisConfig fields in elections pallet tests
* Use new naming scheme for Event enum in election provider multi-phase pallet tests
* Use new naming scheme for Event enum in elections phragmen pallet tests
* Use new naming scheme for GenesisConfig fields in chain spec
* Use new naming scheme for Event enum in staking pallet mock
* Use new naming scheme for GenesisConfig fields in node-template chain spec
* Use new naming scheme for GenesisConfig fields in node-testing chain spec
* Use new naming scheme for Event enum in node executor tests
* Use new naming scheme for GenesisConfig fields in transaction storage pallet mock
* Refactor match conditions
* Make grandpa work
* Introduce `SharedData`
* Add test and fix bugs
* Switch to `SharedData`
* Make grandpa tests working
* More Babe work
* Make it async
* Fix fix
* Use `async_trait` in sc-consensus-slots
This makes the code a little bit easier to read and also expresses that
there can always only be one call at a time to `on_slot`.
* Make grandpa tests compile
* More Babe tests work
* Fix network test
* Start fixing service test
* Finish service-test
* Fix sc-consensus-aura
* Fix fix fix
* More fixes
* Make everything compile *yeah*
* Fix build when we have Rust 1.51
* Update client/consensus/common/src/shared_data.rs
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
* Update client/consensus/common/src/shared_data.rs
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
* Update client/consensus/common/src/shared_data.rs
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
* Update client/consensus/common/src/shared_data.rs
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
* Update client/consensus/common/src/shared_data.rs
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
* Update client/consensus/babe/src/tests.rs
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
* Update client/consensus/babe/src/tests.rs
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
* Fix warning
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
* Use 'Pallet' struct in construct_runtime.
* Fix genesis and metadata macro.
* Fix 'Pallet' type alias.
* Replace 'Module' with 'Pallet' for all construct_runtime use cases.
* Replace more deprecated 'Module' struct.
* Bring back AllModules and AllPalletsWithSystem type, but deprecate them.
* Replace deprecated 'Module' struct from merge master.
* Minor fix.
* Fix UI tests.
* Revert UI override in derive_no_bound.
* Fix more deprecated 'Module' use from master branch.
* Fix more deprecated 'Module' use from master branch.
* contracts: Convert to framev2
* Reduce the API surface of the crate
* Remove unused import
* Merge import block
* Use pallet::metadata to reduce metadata diff
* Remove the explicit "Null" from AccountCounter
* Initial migration of balances pallet
* Fix some errors
* Remove unused imports
* Formatting and removing some todos
* Delete Subtrait
* Add genesis builder impls for tests
* Fix GenesisConfig impl
* Make set_balance visible to tests, rename RawEvent to Event
* Fix tests with Event rename etc.
* More test RawEvent renames
* Even more RawEvent renames
* Rename module to pallet in comments
* Add PalletInfo impl to avid storage collision, fixes tests
* Apply review suggestion: remove trailing a
Co-authored-by: David <dvdplm@gmail.com>
* BalancesEvent alias
* Remove BalancesEvent alias
* Review suggestion: remove redundant comment
* Apply review suggestion: make vis super
* Fis doc links
* Add RawEvent alias
* Add missing Instance parameter to deprecated RawEvent alias
* Fix RawEvent deprecation warnings
Co-authored-by: David <dvdplm@gmail.com>
* contracts: Implement refcounting for wasm code
* contracts: Charge rent for code storage
* contracts: Fix dispatchables erroneously refunding base costs
* Fixed typos in comments.
Co-authored-by: Andrew Jones <ascjones@gmail.com>
* Remove awkward empty line
* Fix more typos in docs
* Fix typos in docs
Co-authored-by: Andrew Jones <ascjones@gmail.com>
* Split up complicated expression
Co-authored-by: Andrew Jones <ascjones@gmail.com>
* review: Remove unused return value
* Fix typos
Co-authored-by: Andrew Jones <ascjones@gmail.com>
* review: Fix refcount being reset to one on re-instrumentation
* Document evictable_code parameter
* Make Executable::execute consume and store itself
* Added comments about stale values
* Disregard struct size in occupied_storage()
Co-authored-by: Andrew Jones <ascjones@gmail.com>
* 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>
* 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
* Asyncify sign_with
* Asyncify generate/get keys
* Complete BareCryptoStore asyncification
* Cleanup
* Rebase
* Add Proxy
* Inject keystore proxy into extensions
* Implement some methods
* Await on send
* Cleanup
* Send result over the oneshot channel sender
* Process one future at a time
* Fix cargo stuff
* Asyncify sr25519_vrf_sign
* Cherry-pick and fix changes
* Introduce SyncCryptoStore
* SQUASH ME WITH THE first commit
* Implement into SyncCryptoStore
* Implement BareCryptoStore for KeystoreProxyAdapter
* authority-discovery
* AURA
* BABE
* finality-grandpa
* offchain-workers
* benchmarking-cli
* sp_io
* test-utils
* application-crypto
* Extensions and RPC
* Client Service
* bin
* Update cargo.lock
* Implement BareCryptoStore on proxy directly
* Simplify proxy setup
* Fix authority-discover
* Pass async keystore to authority-discovery
* Fix tests
* Use async keystore in authority-discovery
* Rename BareCryptoStore to CryptoStore
* WIP
* Remote mutable borrow in CryptoStore trait
* Implement Keystore with backends
* Remove Proxy implementation
* Fix service builder and keystore user-crates
* Fix tests
* Rework authority-discovery after refactoring
* futures::select!
* Fix multiple mut borrows in authority-discovery
* Merge fixes
* Require sync
* Restore Cargo.lock
* PR feedback - round 1
* Remove Keystore and use LocalKeystore directly
Also renamed KeystoreParams to KeystoreContainer
* Join
* Remove sync requirement
* Fix keystore tests
* Fix tests
* client/authority-discovery: Remove event stream dynamic dispatching
With authority-discovery moving from a poll based future to an `async`
future Rust has difficulties propagating the `Sync` trade through the
generated state machine.
Instead of using dynamic dispatching, use a trait parameter to specify
the DHT event stream.
* Make it compile
* Fix submit_transaction
* Fix block_on issue
* Use await in async context
* Fix manual seal keystore
* Fix authoring_blocks test
* fix aura authoring_blocks
* Try to fix tests for auth-discovery
* client/authority-discovery: Fix lookup_throttling test
* client/authority-discovery: Fix triggers_dht_get_query test
* Fix epoch_authorship_works
* client/authority-discovery: Remove timing assumption in unit test
* client/authority-discovery: Revert changes to termination test
* PR feedback
* Remove deadcode and mark test code
* Fix test_sync
* Use the correct keyring type
* Return when from_service stream is closed
* Convert SyncCryptoStore to a trait
* Fix line width
* Fix line width - take 2
* Remove unused import
* Fix keystore instantiation
* PR feedback
* Remove KeystoreContainer
* Revert "Remove KeystoreContainer"
This reverts commit ea4a37c7d74f9772b93d974e05e4498af6192730.
* Take a ref of keystore
* Move keystore to dev-dependencies
* Address some PR feedback
* Missed one
* Pass keystore reference - take 2
* client/finality-grandpa: Use `Arc<dyn CryptoStore>` instead of SyncXXX
Instead of using `SyncCryptoStorePtr` within `client/finality-grandpa`,
which is a type alias for `Arc<dyn SyncCryptoStore>`, use `Arc<dyn
CryptoStore>`. Benefits are:
1. No additional mental overhead of a `SyncCryptoStorePtr`.
2. Ability for new code to use the asynchronous methods of `CryptoStore`
instead of the synchronous `SyncCryptoStore` methods within
`client/finality-granpa` without the need for larger refactorings.
Note: This commit uses `Arc<dyn CryptoStore>` instead of
`CryptoStorePtr`, as I find the type signature more descriptive. This is
subjective and in no way required.
* Remove SyncCryptoStorePtr
* Remove KeystoreContainer & SyncCryptoStorePtr
* PR feedback
* *: Use CryptoStorePtr whereever possible
* *: Define SyncCryptoStore as a pure extension trait of CryptoStore
* Follow up to SyncCryptoStore extension trait
* Adjust docs for SyncCryptoStore as Ben suggested
* Cleanup unnecessary requirements
* sp-keystore
* Use async_std::task::block_on in keystore
* Fix block_on std requirement
* Update primitives/keystore/src/lib.rs
Co-authored-by: Max Inden <mail@max-inden.de>
* Fix wasm build
* Remove unused var
* Fix wasm compilation - take 2
* Revert async-std in keystore
* Fix indent
* Fix version and copyright
* Cleanup feature = "std"
* Auth Discovery: Ignore if from_service is cloed
* Max's suggestion
* Revert async-std usage for block_on
* Address PR feedback
* Fix example offchain worker build
* Address PR feedback
* Update Cargo.lock
* Move unused methods to test helper functions
* Restore accidentally deleted cargo.lock files
* Fix unused imports
Co-authored-by: Max Inden <mail@max-inden.de>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
* seal: Change prefix "ext_" to "seal_" for contract callable functions
The word Ext is a overloaded term in the context of substrate. It usually
is a trait which abstracts away access to external resources usually in order
to mock them away for the purpose of tests. The contract module has its own
`Ext` trait in addition the the substrate `Ext` which makes things even more
confusing.
In order to differentiate the contract callable functions more clearly from
this `Ext` concept we rename them to use the "seal_" prefix instead.
This should change no behaviour at all. This is a pure renaming commit.
* seal: Rename import module from "env" to "seal0"
* seal: Fixup integration test
* seal: Add more tests for new import module names
* 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: 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
* Transition getter functions to not use scratch buffer
* Remove scratch buffer from ext_get_storage
* Remove scratch buffer from ext_call
* Remove scratch buffer from ext_instantiate
* Add ext_input and remove scratch buffer
* Rework error handling (changes RPC exposed data)
* ext_return passes a flags field instead of a return code
* Flags is only for seal and not for the caller
* flags: u32 replaced status_code: u8 in RPC exposed type
* API functions use a unified error type (ReturnCode)
* ext_transfer now traps on error to be consistent with call and instantiate
* Remove the no longer used `Dispatched` event
* Updated inline documentation
* Prevent skipping of copying the output for getter API
* Return gas_consumed from the RPC contracts call interface
* Updated COMPLEXTITY.md
* Rename ext_gas_price to ext_weight_to_fee
* Align comments with spaces
* Removed no longer used `ExecError`
* Remove possible panic in `from_typed_value`
* Use a struct as associated data for SpecialTrap::Return
* Fix nits in COMPLEXITY.md
* Renamed SpecialTrap to TrapReason
* Fix test
* Finish renaming special_trap -> trap_reason
* Remove no longer used get_runtime_storage
* fixup! Remove no longer used get_runtime_storage
* Removed tabs for comment aligment
* Initial draft, has some todos left
* remove ununsed import
* Apply suggestions from code review
* Some refactors with migration
* Fix more test and cleanup
* Fix for companion
* Apply suggestions from code review
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
* Update bin/node/runtime/src/impls.rs
* Fix weight
* Add integrity test
* length is not affected.
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
* Emit a PaymentParameters event once per block
This contains per-block paramaters need to calculate
fees off-chain.
* Add WeightToFee trait
* Add documentation to polynomial types
* Ignore pseudo code snippet for doc tests
* Use `Mul` implementation of Perbill
* Add tests for WeightToFeePolynomial
* Revert "Emit a PaymentParameters event once per block"
This reverts commit 6c4763baff3d8179676a3c1660fe7063fd56a8ca.
Co-authored-by: Gavin Wood <gavin@parity.io>
* Add ‘transaction_version’ to the signed transaction
This allows hardware wallets to know which transactions they can safely
sign. To reduce transaction size, I reduced it to a ‘u8’ from a ‘u32’.
Fixes#5951.
* Restore transaction_version to a u32
* Fix comments
`transaction_version` is not part of a tx, but is still signed.
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
* Fix the test suite
I had forgotten to change the production of transactions in the test
code.
* Fix benchmarks
* Improve docs for `CheckTxVersion` in `frame_system`
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
* Remove spurious cast
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
* Move weight values to `frame_support`
* more accurate comment
* update balances
* vesting
* update util
* Add weight to time constants
* use weight constants in weights
* update tests
* start to try and implement noop
* txs as input
* better comment
* Add transfer reaping
* rename to avoid filter matching
* Update base weights based on results
* fix priority
* fix logic on reaping transfer
* Update bin/node/bench/src/import.rs
Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
* Update bin/node/bench/src/main.rs
Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
* add back size type (in-progress)
* bring back size type with custom
* update comment
* nit
* block type then size
* Use `transfer_keep_alive`
Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
* calculate weight for timestamp::set
* reduce db count in kill_identity weight calculation
* return weight of on_finalize in on_initialize
* add comment
* import Weight
* address review comments to update db weight count
* fix full block import test
* update weights and benchmark info to latest benchmark data
* update identity pallet weights and benchmark info
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
* Introduce `BlockExectionWeight` and `ExtrinsicBaseWeight`
* Add new traits everywhere
* Missed one update
* fix tests
* Update `check_weight` logic
* introduce `max_extrinsic_weight` function
* fix + add tests
* format nits
* remove println
* make test a bit more clear
* Remove minimum weight
* newlines left over from find/replace
* Fix test, improve clarity
* Fix executor tests
* Extrinsic base weight same as old `MINIMUM_WEIGHT`
* fix example test
* Expose constants
* Add test for full block with operational and normal
* Initiate test environment with `BlockExecutionWeight` weight
* format nit
* Update frame/system/src/lib.rs
Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
* Replace `TransactionBaseFee` with `ExtrinsicBaseWeight` (#5761)
* Replace `TransactionBaseFee` with `ExtrinsicBaseFee`
* Fix stuff
* Fix and make tests better
* Forgot to update this test
* Fix priority number in test
* Remove minimum weight from merge
* Fix weight in contracts
* remove `TransactionBaseFee` from contract tests
* Let `register_extra_weight_unchecked` go past `MaximumBlockWeight`
* address feedback
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>