Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
173 commits
Select commit Hold shift + click to select a range
021f712
Update contract weights (#12192)
athei Sep 7, 2022
5e2ffeb
Move Get and bounded types to sp-core (#12203)
KiChjang Sep 7, 2022
c0e1cdb
Add `--header` to `benchmark overhead + storage` (#12204)
ggwpez Sep 7, 2022
2619394
Remove Ord impl for Weights V2 and add comparison fns (#12183)
KiChjang Sep 8, 2022
8075aa4
pallet-identity: Be more paranoid ;) (#12170)
bkchr Sep 8, 2022
e202092
Upgrade wasmtime to 0.40.0 (#12096)
bkchr Sep 8, 2022
0478535
Use parameter_types instead of thread_local for test-setup (#12036)
tifecool Sep 8, 2022
cd66db5
Fully remove `rusty-cachier` from the `node-bench-regression-guard` j…
rcny Sep 8, 2022
b8c3d8c
Upgrade wasm crate dependencies (#12173)
athei Sep 8, 2022
f9fdee1
Removing without_storage_info from scored-pool pallet. (#11996)
hbulgarini Sep 8, 2022
c8bfc91
Update ss58-registry (#12220)
MOZGIII Sep 8, 2022
5a48536
Add missing metadata specs to crate manifests (#12221)
Sep 8, 2022
51f60d0
construct_runtime: Fix generation of types behind features (#12229)
bkchr Sep 10, 2022
7de3d78
Remove native call (#12201)
bkchr Sep 12, 2022
d5de897
Fuzz testing for nomination pools (#12002)
kianenigma Sep 12, 2022
c997a62
Add `ConstFeeMultiplier` to the transaction payment pallet (#12222)
mrshiposha Sep 12, 2022
7cb78ff
Don't run `cargo-check-benches` for `master` based downstream staging…
rcny Sep 12, 2022
dd1f1b5
Expose some of the staking miner types over metadata (#12245)
kianenigma Sep 12, 2022
f1c60e5
extract some grandpa types to Primitives crate (#12208)
yjhmelody Sep 12, 2022
5527263
BREAKING: Rename Call & Event (#11981)
Szegoo Sep 12, 2022
379813c
Update README (#12247)
nuke-web3 Sep 13, 2022
5daa20c
Add inspect trait for asset roles (#11738)
girazoki Sep 13, 2022
c1103fd
Move bitswap to its own crate (#12242)
altonen Sep 13, 2022
9df9448
benches: disable caching per default (#12232)
ggwpez Sep 13, 2022
bb7fb64
Make `BasePath::new_temp_dir` return the same path for the program li…
bkchr Sep 13, 2022
3449fb0
Remove CanAuthorWith trait (#12213)
michalkucharczyk Sep 13, 2022
23bb5a6
Create sp-weights crate to store weight primitives (#12219)
KiChjang Sep 13, 2022
b5e2542
fix sp-weight std (#12265)
shawntabrizi Sep 14, 2022
7c2c0c1
Improve base weights consistency and make sure they're never zero (#1…
koute Sep 14, 2022
dc22e48
Fix Rust features (#11976)
ggwpez Sep 14, 2022
1dcb9ce
Clean up the logging output (#12253)
bkchr Sep 14, 2022
fd54957
Bump wasm-instrument (#12234)
athei Sep 15, 2022
3bef1ba
Include Bitswap into request response protocols (#12262)
altonen Sep 15, 2022
12b5b5a
Use `--locked` for Cargo in CI everywhere (#12270)
rcny Sep 15, 2022
8bd5510
Replace 'blake2-rfc' with rust-crypto 'blake2' crate (#12266)
davxy Sep 15, 2022
21adbaf
Expose tracks as a constant. (#12273)
gavofyork Sep 15, 2022
d65f4bb
client/beefy: fix voter initialization (#12274)
acatangiu Sep 16, 2022
7202ca6
Fix warp sync (#12281)
arkpar Sep 16, 2022
4d04aba
Add special tag to exclude runtime storage items from benchmarking (#…
sam0x17 Sep 16, 2022
03eb807
[Feature] Part 1: add TargetList for validator ranking (#12034)
ruseinov Sep 18, 2022
91b97b0
[Fix] Benchmark issue in staking (#12290)
ruseinov Sep 18, 2022
ee3c159
support upgrade hooks to directly pass data (#12185)
NingLin-P Sep 19, 2022
b541b2d
contracts: Use `WeakBoundedVec` for instrumented code (#12186)
athei Sep 19, 2022
c24431e
Fix CI (#12297)
ggwpez Sep 19, 2022
df3722c
Fix `cargo-check-benches` job (#12301)
rcny Sep 20, 2022
625de4f
[ci] Revert cancel-pipeline job (#12309)
alvicsam Sep 20, 2022
e7c515d
Proper naming wrt expectations (#12311)
sandreim Sep 20, 2022
97ad64b
Import target block body during warp sync (#12300)
dmitry-markin Sep 20, 2022
de5a7f6
rpc: Implement `chainSpec` RPC API (#12261)
lexnv Sep 20, 2022
006dbc0
Use temporary db for benchmarking (#12254)
michalkucharczyk Sep 20, 2022
a47f200
BREAKING: Rename Origin (#12258)
Szegoo Sep 20, 2022
409167e
Use `array-bytes` for All Array/Bytes/Hex Operations (#12190)
aurexav Sep 21, 2022
4e53bdc
Bound staking storage items (#12230)
Ank4n Sep 21, 2022
9df7ac8
Introduce 'intermediate_insert' method to hide implementation details…
davxy Sep 21, 2022
ae4ba19
Bump `wasmtime` to 1.0.0 (#12317)
koute Sep 21, 2022
be97615
Format templates and fix `--steps` default value (#12286)
ggwpez Sep 21, 2022
493b58b
Make automatic storage deposits resistant against changing deposit pr…
athei Sep 21, 2022
1253de6
pallet-utility: Disallow none origin (#12321)
bkchr Sep 22, 2022
cc4d5cc
Migrate remaining old decl_* macros to the new pallet attribute macro…
koushiro Sep 22, 2022
1f720c1
Rename anonymous to pure proxy (#12283)
shawntabrizi Sep 22, 2022
bffd6a3
Fast Unstake Pallet (#12129)
kianenigma Sep 23, 2022
397da27
bench: Use `_` instead of `::` in auto-generated file names (#12332)
ggwpez Sep 23, 2022
8161ee1
[Feature] Sequential migration execution for try-runtime (#12319)
ruseinov Sep 23, 2022
b34936a
[Fix] parameter_types! dead code errors (#12340)
ruseinov Sep 23, 2022
ffcd523
Independence of Slot-based algorithms from system Timestamp (#12224)
davxy Sep 23, 2022
fb77921
Const impls of base arithmetics for `Weights` with `u64` (#12322)
mustermeiszer Sep 24, 2022
9476d21
Add base-weight to `System::Extrinsic*` events (#12329)
ggwpez Sep 24, 2022
d0214e7
re add the migration checks for staking (#12330)
Ank4n Sep 24, 2022
4219b3a
Allow specifying immediate finalize for `manual-seal` (#12106)
cmichi Sep 25, 2022
badc92a
Removed OuterCall alias & doc fixes (#12349)
Szegoo Sep 25, 2022
fbd7e5a
[Enhancement] Remove optional Pool subscription from fast-unstake (#1…
ruseinov Sep 26, 2022
a0ec652
Remove discarded blocks and states from database by default (#11983)
hzy1919 Sep 26, 2022
0dbeaa0
re-export weight file for fast-unstsake pallet (#12352)
kianenigma Sep 26, 2022
f360c87
Move transactions protocol to its own crate (#12264)
altonen Sep 26, 2022
519fbaa
export more types from fast-untsake 🤦‍♂️ (#12353)
kianenigma Sep 27, 2022
1763ff2
Fix compilation on 1.66 nightly (#12363)
bkchr Sep 27, 2022
edca891
Relax Slots-based engines from Epochs (#12360)
davxy Sep 27, 2022
2a6c314
Pallet staking events to named enum (#12342)
Szegoo Sep 27, 2022
74daaf1
[fix] Bound staking ledger correctly with MaxUnlockingChunks from con…
Ank4n Sep 27, 2022
94b9646
[Feature] Add deposit to fast-unstake (#12366)
ruseinov Sep 27, 2022
2ee4cb4
Add missing CountedStorageMap in pallet::storage error info (#12356)
liuchengxu Sep 27, 2022
17c07af
Add storage size component to weights (#12277)
KiChjang Sep 28, 2022
01a905e
pallet-utility: Only disallow the `None` origin (#12351)
bkchr Sep 28, 2022
1b1a5e1
Fix staking migration (#12373)
ggwpez Sep 28, 2022
0ec4373
Support running the pallet benchmarks analysis without running the be…
koute Sep 28, 2022
d66adfa
fix: typo in AllPalletsWithSystem deprecated msg (#12379)
Sep 28, 2022
96de768
New Pallet: Root offences (#11943)
Szegoo Sep 28, 2022
e7f994d
bounding staking: `BoundedElectionProvider` trait (#12362)
Ank4n Sep 28, 2022
427fd09
BEEFY: impl TypeInfo for SignedCommitment (#12382)
serban300 Sep 29, 2022
61b9a4d
Properly set the max proof size weight on defaults and tests (#12383)
KiChjang Sep 29, 2022
c2026ca
Carry over where clauses defined in Config to Call and Hook (#12388)
KiChjang Sep 30, 2022
dbb72f3
unsafe_pruning flag removed (#12385)
michalkucharczyk Sep 30, 2022
952030c
pallet-mmr: generate historical proofs (#12324)
serban300 Sep 30, 2022
37664fe
Remove contracts RPCs (#12358)
athei Oct 2, 2022
9472af8
Beefy on-demand justifications as a custom RequestResponse protocol (…
acatangiu Oct 3, 2022
2579550
Fix `Weight::is_zero` (#12396)
ggwpez Oct 3, 2022
1b23ec9
Remove unnecessary Clone trait bounds on CountedStorageMap (#12402)
KiChjang Oct 3, 2022
6d7f76b
docs/CODEOWNERS: add @acatangiu as MMR owner (#12406)
acatangiu Oct 4, 2022
594d71a
Add @koute to `docs/CODEOWNERS` and update stale paths (#12408)
koute Oct 4, 2022
e77cbe3
BEEFY: Simplify hashing for pallet-beefy-mmr (#12393)
serban300 Oct 4, 2022
0051950
client/beefy: small code improvements (#12414)
acatangiu Oct 4, 2022
07e5ec5
[Fix] Rename VoterBagsList -> VoterList to match pdot (#12416)
ruseinov Oct 4, 2022
d11dd02
Use saturating add for alliance::disband witness data (#12418)
muharem Oct 4, 2022
91d072d
Bump prost to 0.11+ (#12419)
chevdor Oct 4, 2022
241b0d0
Improved election pallet testing (#12327)
Szegoo Oct 4, 2022
7a8de49
Adapt `pallet-contracts` to WeightV2 (#12421)
athei Oct 5, 2022
2cd4088
MMR: impl `TypeInfo` for some structures (#12423)
serban300 Oct 5, 2022
4cd3248
Don't send back empty proofs if light request fails (#12372)
tomaka Oct 5, 2022
87224cf
Implement `Clone` and `Default` for `Config` (#12397)
s0me0ne-unkn0wn Oct 5, 2022
eefba93
Bound uses of `Call` (#11649)
gavofyork Oct 5, 2022
fc67cbb
update kvdb & co (#12312)
Oct 5, 2022
f447bee
Use `Option<Weight>` for contract dry-runs (#12429)
athei Oct 6, 2022
3cb5a40
Add pluggable BEEFY payload constructors (#12428)
acatangiu Oct 6, 2022
a84def9
Maximum value for `MultiplierUpdate` (#12282)
Szegoo Oct 6, 2022
f77f788
macro stubs for all pallet:: macros to improve documentation visibili…
sam0x17 Oct 6, 2022
4a5a9de
Upgrade pin-project (#12426)
bkchr Oct 7, 2022
a8e951d
Extend the lower bounds of some of the benchmarks to also include `0`…
koute Oct 7, 2022
1a5cdc8
BEEFY: Define a `BeefyVerify` trait for signatures (#12299)
serban300 Oct 7, 2022
b7c0562
fix comment math (#12452)
nuke-web3 Oct 8, 2022
460fff9
Remove "to_block" field from BlockRequests (#12447)
tomaka Oct 8, 2022
73c4f94
Vesting pallet - make WithdrawReasons configurable (#12109)
Lezek123 Oct 9, 2022
0c1ccda
Move block announcement protocol config out of `Protocol` (#12441)
altonen Oct 10, 2022
df81976
Dont ignore errors in pallet benchmarking (#12449)
ggwpez Oct 10, 2022
9672c36
Update UI tests for Rust 1.64 (#12440)
rcny Oct 10, 2022
488fc24
rpc: Implement `transaction` RPC API (#12328)
lexnv Oct 11, 2022
60be7b8
Remove the unused light client requests (#12470)
tomaka Oct 11, 2022
6072b90
Fix flaky service test (#12472)
altonen Oct 11, 2022
1bf2e6d
Rename `from_components` to `from_parts` (#12473)
KiChjang Oct 11, 2022
ccc8f6c
Avoid Unstable Sort (#12455)
shawntabrizi Oct 11, 2022
94b731c
Finalized block event triggers tx maintanance (#12305)
michalkucharczyk Oct 11, 2022
88db102
tx-pool: failing tests fixed (#12481)
michalkucharczyk Oct 12, 2022
06a9f0a
Clarify the "direction" field of block requests (#12438)
tomaka Oct 12, 2022
f8a0b7a
BlockId::Number refactor: trivial changes to BlockId::Hash (#12471)
michalkucharczyk Oct 12, 2022
b324e51
Dont use benchmark range on constant functions (#12456)
shawntabrizi Oct 12, 2022
94941a8
Punish peers for duplicate GRANDPA neighbor messages (#12462)
dmitry-markin Oct 13, 2022
983b6b0
Introduce mockable `ChainSync` object for testing (#12480)
altonen Oct 13, 2022
1f39c90
pallet-mmr: RPC API and Runtime API work with block numbers (#12345)
Szegoo Oct 13, 2022
fd00b14
Enable the `wasmtime`-based WASM executor by default (#12486)
koute Oct 13, 2022
6e04e48
Trivial BlockId::Number => Hash (#12490)
michalkucharczyk Oct 13, 2022
f313987
BlockId removal: refactor: Backend::state_at (#12488)
michalkucharczyk Oct 14, 2022
0ee0327
Try-runtime CLI fix weight parsing (#12491)
ggwpez Oct 14, 2022
6f453b5
Export fn code_hash (#12479)
kvinwang Oct 17, 2022
30a7a5b
Introduce `ChainSyncInterface` (#12489)
altonen Oct 17, 2022
951f075
sp-api: Remove invalid unsafe trait bounds (#12502)
bkchr Oct 17, 2022
273e264
pallet-mmr: fix offchain db for sync from zero (#12498)
acatangiu Oct 17, 2022
acacb53
Fix: typo (#12505)
omahs Oct 17, 2022
444cf9d
Upgrade libp2p to 0.49.0 (#12256)
dmitry-markin Oct 17, 2022
ed2466e
Execute try-state at end of each test to ensure pallet data integrity…
Ank4n Oct 17, 2022
e8a4408
Bump clap to 4.0.x and adjust to best practices (#12381)
skunert Oct 18, 2022
b9a555d
implement storage decode length for BTreeSet (#12503)
dharjeezy Oct 18, 2022
415648d
Decrease default --out-peers from 25 to 15 (#12434)
tomaka Oct 18, 2022
4c45673
Prepare for latest clippy (nightly 09-10-2022) (#12466)
bkchr Oct 18, 2022
281bcd4
derive Serialize/Deserialize for BeefyAuthoritySet (#12516)
serban300 Oct 18, 2022
e34b840
BlockId removal: refactor: StorageProvider (#12510)
michalkucharczyk Oct 18, 2022
487ac5c
Use `ArgAction::Set` for enable-offchain-indexing flag (#12521)
skunert Oct 18, 2022
49734dd
frame/utils: introduce `substrate-rpc-client` crate for RPC utils (#1…
niklasad1 Oct 18, 2022
399ab89
Force base weights to be the minimum only when the intercept is negat…
koute Oct 20, 2022
7a4e516
Update `pallet-multisig` benches (#12558)
ggwpez Oct 26, 2022
7eab46f
resolve conflicts version 31
devdanco Nov 14, 2022
6304e5a
Update TargetedFeeAdjustment struct
devdanco Nov 18, 2022
1dfd9b4
Merge branch 'mangata-dev' into mangata-dev-v0.9.31
devdanco Nov 28, 2022
c2f6367
add feature to crate
devdanco Nov 28, 2022
1f23be6
update orml version in test
devdanco Nov 28, 2022
f61d829
remove unnecessary try-runtime feature
devdanco Nov 30, 2022
3696593
feat: resolve confclits and fix fmt
devdanco Dec 12, 2022
b31aa9d
fix: benchmarking types
devdanco Dec 13, 2022
7b6b521
Merge branch 'mangata-dev' into mangata-dev-v0.9.31
devdanco Dec 20, 2022
c5a1bbe
feat: resolve conflicts after storage queue
devdanco Dec 21, 2022
34c492c
fix: tests
devdanco Dec 21, 2022
a73d548
Added pre and post upgrade hooks for try0runtime and remove pallet-tr…
Dec 23, 2022
f84f481
Minor try-runtime bug
Dec 23, 2022
61bcb2e
fix: inject inherets
devdanco Dec 30, 2022
3d36c5e
update reference
devdanco Dec 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make automatic storage deposits resistant against changing deposit pr…
…ices (paritytech#12083)

* Require `FixedPointOperand` for Balances

* Delay deposit calculation

* Make refunds pro rata of consumed storage

* Add storage migration

* Fix clippy

* Add liquidity checks

* Fixe delayed deposit limit enforcement

* Defer charges

* Import Vec

* Add try-runtime hooks for migration

* Fix warning

* Adapt to new OnRuntimeUpgrade trait

* Apply suggestions from code review

Co-authored-by: Sasha Gryaznov <[email protected]>

* fmt

* Apply suggestions from code review

Co-authored-by: Sasha Gryaznov <[email protected]>

* More suggestions from code review

Co-authored-by: Sasha Gryaznov <[email protected]>
  • Loading branch information
athei and agryaznov authored Sep 21, 2022
commit 493b58bd4a475080d428ce47193ee9ea9757a808
1 change: 1 addition & 0 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,7 @@ pub type Executive = frame_executive::Executive<
type Migrations = (
pallet_nomination_pools::migration::v2::MigrateToV2<Runtime>,
pallet_alliance::migration::Migration<Runtime>,
pallet_contracts::Migration<Runtime>,
);

/// MMR helper types.
Expand Down
5 changes: 3 additions & 2 deletions frame/balances/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ use sp_runtime::{
AtLeast32BitUnsigned, Bounded, CheckedAdd, CheckedSub, MaybeSerializeDeserialize,
Saturating, StaticLookup, Zero,
},
ArithmeticError, DispatchError, RuntimeDebug,
ArithmeticError, DispatchError, FixedPointOperand, RuntimeDebug,
};
use sp_std::{cmp, fmt::Debug, mem, ops::BitOr, prelude::*, result};
pub use weights::WeightInfo;
Expand All @@ -212,7 +212,8 @@ pub mod pallet {
+ MaybeSerializeDeserialize
+ Debug
+ MaxEncodedLen
+ TypeInfo;
+ TypeInfo
+ FixedPointOperand;

/// Handler for the unbalanced reduction when removing a dust account.
type DustRemoval: OnUnbalanced<NegativeImbalance<Self, I>>;
Expand Down
55 changes: 55 additions & 0 deletions frame/contracts/fixtures/create_storage_and_call.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
;; This calls another contract as passed as its account id. It also creates some storage.
(module
(import "seal0" "seal_input" (func $seal_input (param i32 i32)))
(import "seal0" "seal_set_storage" (func $seal_set_storage (param i32 i32 i32)))
(import "seal1" "seal_call" (func $seal_call (param i32 i32 i64 i32 i32 i32 i32 i32) (result i32)))
(import "env" "memory" (memory 1 1))

(func $assert (param i32)
(block $ok
(br_if $ok
(get_local 0)
)
(unreachable)
)
)

(func (export "deploy"))

(func (export "call")
;; store length of input buffer
(i32.store (i32.const 0) (i32.const 512))

;; copy input at address 4
(call $seal_input (i32.const 4) (i32.const 0))

;; create 4 byte of storage before calling
(call $seal_set_storage
(i32.const 0) ;; Pointer to storage key
(i32.const 0) ;; Pointer to value
(i32.const 4) ;; Size of value
)

;; call passed contract
(call $assert (i32.eqz
(call $seal_call
(i32.const 0) ;; No flags
(i32.const 8) ;; Pointer to "callee" address.
(i64.const 0) ;; How much gas to devote for the execution. 0 = all.
(i32.const 512) ;; Pointer to the buffer with value to transfer
(i32.const 4) ;; Pointer to input data buffer address
(i32.const 4) ;; Length of input data buffer
(i32.const 4294967295) ;; u32 max value is the sentinel value: do not copy output
(i32.const 0) ;; Length is ignored in this case
)
))

;; create 8 byte of storage after calling
;; item of 12 bytes because we override 4 bytes
(call $seal_set_storage
(i32.const 0) ;; Pointer to storage key
(i32.const 0) ;; Pointer to value
(i32.const 12) ;; Size of value
)
)
)
18 changes: 9 additions & 9 deletions frame/contracts/src/benchmarking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ where
module: WasmModule<T>,
data: Vec<u8>,
) -> Result<Contract<T>, &'static str> {
let value = T::Currency::minimum_balance();
let value = Pallet::<T>::min_balance();
T::Currency::make_free_balance_be(&caller, caller_funding::<T>());
let salt = vec![0xff];
let addr = Contracts::<T>::contract_address(&caller, &module.hash, &salt);
Expand Down Expand Up @@ -257,7 +257,7 @@ benchmarks! {
let instance = Contract::<T>::with_caller(
whitelisted_caller(), WasmModule::sized(c, Location::Deploy), vec![],
)?;
let value = T::Currency::minimum_balance();
let value = Pallet::<T>::min_balance();
let origin = RawOrigin::Signed(instance.caller.clone());
let callee = instance.addr;
}: call(origin, callee, value, Weight::MAX, None, vec![])
Expand All @@ -280,7 +280,7 @@ benchmarks! {
let c in 0 .. Perbill::from_percent(49).mul_ceil(T::MaxCodeLen::get());
let s in 0 .. code::max_pages::<T>() * 64 * 1024;
let salt = vec![42u8; s as usize];
let value = T::Currency::minimum_balance();
let value = Pallet::<T>::min_balance();
let caller = whitelisted_caller();
T::Currency::make_free_balance_be(&caller, caller_funding::<T>());
let WasmModule { code, hash, .. } = WasmModule::<T>::sized(c, Location::Call);
Expand All @@ -307,7 +307,7 @@ benchmarks! {
instantiate {
let s in 0 .. code::max_pages::<T>() * 64 * 1024;
let salt = vec![42u8; s as usize];
let value = T::Currency::minimum_balance();
let value = Pallet::<T>::min_balance();
let caller = whitelisted_caller();
T::Currency::make_free_balance_be(&caller, caller_funding::<T>());
let WasmModule { code, hash, .. } = WasmModule::<T>::dummy();
Expand Down Expand Up @@ -338,7 +338,7 @@ benchmarks! {
let instance = Contract::<T>::with_caller(
whitelisted_caller(), WasmModule::dummy(), vec![],
)?;
let value = T::Currency::minimum_balance();
let value = Pallet::<T>::min_balance();
let origin = RawOrigin::Signed(instance.caller.clone());
let callee = instance.addr.clone();
let before = T::Currency::free_balance(&instance.account_id);
Expand Down Expand Up @@ -767,13 +767,13 @@ benchmarks! {
let instance = Contract::<T>::new(code, vec![])?;
let origin = RawOrigin::Signed(instance.caller.clone());
assert_eq!(T::Currency::total_balance(&beneficiary), 0u32.into());
assert_eq!(T::Currency::free_balance(&instance.account_id), T::Currency::minimum_balance());
assert_eq!(T::Currency::free_balance(&instance.account_id), Pallet::<T>::min_balance());
assert_ne!(T::Currency::reserved_balance(&instance.account_id), 0u32.into());
}: call(origin, instance.addr.clone(), 0u32.into(), Weight::MAX, None, vec![])
verify {
if r > 0 {
assert_eq!(T::Currency::total_balance(&instance.account_id), 0u32.into());
assert_eq!(T::Currency::total_balance(&beneficiary), T::Currency::minimum_balance());
assert_eq!(T::Currency::total_balance(&beneficiary), Pallet::<T>::min_balance());
}
}

Expand Down Expand Up @@ -1469,7 +1469,7 @@ benchmarks! {
.collect::<Vec<_>>();
let account_len = accounts.get(0).map(|i| i.encode().len()).unwrap_or(0);
let account_bytes = accounts.iter().flat_map(|x| x.encode()).collect();
let value = T::Currency::minimum_balance();
let value = Pallet::<T>::min_balance();
assert!(value > 0u32.into());
let value_bytes = value.encode();
let value_len = value_bytes.len();
Expand Down Expand Up @@ -1705,7 +1705,7 @@ benchmarks! {
let hash_len = hashes.get(0).map(|x| x.encode().len()).unwrap_or(0);
let hashes_bytes = hashes.iter().flat_map(|x| x.encode()).collect::<Vec<_>>();
let hashes_len = hashes_bytes.len();
let value = T::Currency::minimum_balance();
let value = Pallet::<T>::min_balance();
assert!(value > 0u32.into());
let value_bytes = value.encode();
let value_len = value_bytes.len();
Expand Down
23 changes: 13 additions & 10 deletions frame/contracts/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,15 @@ where
return Ok(output)
}

// Storage limit is enforced as late as possible (when the last frame returns) so that
// the ordering of storage accesses does not matter.
if self.frames.is_empty() {
let frame = &mut self.first_frame;
frame.contract_info.load(&frame.account_id);
let contract = frame.contract_info.as_contract();
frame.nested_storage.enforce_limit(contract)?;
}

let frame = self.top_frame();
let account_id = &frame.account_id;
match (entry_point, delegated_code_hash) {
Expand Down Expand Up @@ -911,12 +920,7 @@ where
// it was invalidated.
frame.contract_info.load(account_id);
let mut contract = frame.contract_info.into_contract();
prev.nested_storage.absorb(
frame.nested_storage,
&self.origin,
account_id,
contract.as_mut(),
);
prev.nested_storage.absorb(frame.nested_storage, account_id, contract.as_mut());

// In case the contract wasn't terminated we need to persist changes made to it.
if let Some(contract) = contract {
Expand Down Expand Up @@ -954,7 +958,6 @@ where
let mut contract = self.first_frame.contract_info.as_contract();
self.storage_meter.absorb(
mem::take(&mut self.first_frame.nested_storage),
&self.origin,
&self.first_frame.account_id,
contract.as_deref_mut(),
);
Expand Down Expand Up @@ -2354,10 +2357,10 @@ mod tests {
let code_bob = MockLoader::insert(Call, |ctx, _| {
if ctx.input_data[0] == 0 {
let info = ctx.ext.contract_info();
assert_eq!(info.storage_deposit, 0);
info.storage_deposit = 42;
assert_eq!(info.storage_byte_deposit, 0);
info.storage_byte_deposit = 42;
assert_eq!(ctx.ext.call(Weight::zero(), CHARLIE, 0, vec![], true), exec_trapped());
assert_eq!(ctx.ext.contract_info().storage_deposit, 42);
assert_eq!(ctx.ext.contract_info().storage_byte_deposit, 42);
}
exec_success()
});
Expand Down
33 changes: 24 additions & 9 deletions frame/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@
mod gas;
mod benchmarking;
mod exec;
mod migration;
mod schedule;
mod storage;
mod wasm;

pub mod chain_extension;
pub mod migration;
pub mod weights;

#[cfg(test)]
Expand All @@ -109,7 +109,10 @@ use codec::{Encode, HasCompact};
use frame_support::{
dispatch::{DispatchClass, Dispatchable, GetDispatchInfo, Pays, PostDispatchInfo},
ensure,
traits::{ConstU32, Contains, Currency, Get, Randomness, ReservableCurrency, Time},
traits::{
tokens::fungible::Inspect, ConstU32, Contains, Currency, Get, Randomness,
ReservableCurrency, Time,
},
weights::Weight,
BoundedVec, WeakBoundedVec,
};
Expand All @@ -126,6 +129,7 @@ use sp_std::{fmt::Debug, marker::PhantomData, prelude::*};

pub use crate::{
exec::{Frame, VarSizedKey as StorageKey},
migration::Migration,
pallet::*,
schedule::{HostFnWeights, InstructionWeights, Limits, Schedule},
};
Expand Down Expand Up @@ -225,7 +229,7 @@ pub mod pallet {
use frame_system::pallet_prelude::*;

/// The current storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(7);
const STORAGE_VERSION: StorageVersion = StorageVersion::new(8);

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
Expand All @@ -236,11 +240,12 @@ pub mod pallet {
/// The time implementation used to supply timestamps to contracts through `seal_now`.
type Time: Time;

/// The generator used to supply randomness to contracts through `seal_random`.
/// The generator used to supply randomness to contracts through `seal_random`
type Randomness: Randomness<Self::Hash, Self::BlockNumber>;

/// The currency in which fees are paid and contract balances are held.
type Currency: ReservableCurrency<Self::AccountId>;
type Currency: ReservableCurrency<Self::AccountId>
+ Inspect<Self::AccountId, Balance = BalanceOf<Self>>;

/// The overarching event type.
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
Expand Down Expand Up @@ -1036,7 +1041,7 @@ where
};
let schedule = T::Schedule::get();
let result = ExecStack::<T, PrefabWasmModule<T>>::run_call(
origin,
origin.clone(),
dest,
&mut gas_meter,
&mut storage_meter,
Expand All @@ -1045,7 +1050,11 @@ where
data,
debug_message,
);
InternalCallOutput { result, gas_meter, storage_deposit: storage_meter.into_deposit() }
InternalCallOutput {
result,
gas_meter,
storage_deposit: storage_meter.into_deposit(&origin),
}
}

/// Internal function that does the actual instantiation.
Expand Down Expand Up @@ -1089,7 +1098,7 @@ where
value.saturating_add(extra_deposit),
)?;
let result = ExecStack::<T, PrefabWasmModule<T>>::run_instantiate(
origin,
origin.clone(),
executable,
&mut gas_meter,
&mut storage_meter,
Expand All @@ -1100,17 +1109,23 @@ where
debug_message,
);
storage_deposit = storage_meter
.into_deposit()
.into_deposit(&origin)
.saturating_add(&StorageDeposit::Charge(extra_deposit));
result
};
InternalInstantiateOutput { result: try_exec(), gas_meter, storage_deposit }
}

/// Deposit a pallet contracts event. Handles the conversion to the overarching event type.
fn deposit_event(topics: Vec<T::Hash>, event: Event<T>) {
<frame_system::Pallet<T>>::deposit_event_indexed(
&topics,
<T as Config>::RuntimeEvent::from(event).into(),
)
}

/// Return the existential deposit of [`Config::Currency`].
fn min_balance() -> BalanceOf<T> {
<T::Currency as Inspect<AccountIdOf<T>>>::minimum_balance()
}
}
Loading