seal_reentrant_count returns contract reentrant count (#12695)

* Add logic, test, broken benchmark

* account_entrance_count

* Addressing comments

* Address @agryaznov's comments

* Add test for account_entrance_count, fix ci

* Cargo fmt

* Fix tests

* Fix tests

* Remove delegated call from test, address comments

* Minor fixes and indentation in wat files

* Update test for account_entrance_count

* Update reentrant_count_call test

* Delegate call test

* Cargo +nightly fmt

* Address comments

* Update reentrant_count_works test

* Apply weights diff

* Add fixture descriptions

* Update comments as suggested

* Update reentrant_count_call test to use seal_address

* add missing code

* cargo fmt

* account_entrance_count -> account_reentrance_count

* fix tests

* fmt

* normalize signatures

Co-authored-by: yarikbratashchuk <yarik.bratashchuk@gmail.com>
This commit is contained in:
Artemka374
2022-11-15 15:12:08 +02:00
committed by GitHub
parent 679d2dcd25
commit 103ea38f95
10 changed files with 569 additions and 1 deletions
+51 -1
View File
@@ -109,6 +109,8 @@ pub trait WeightInfo {
fn seal_ecdsa_recover(r: u32, ) -> Weight;
fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight;
fn seal_set_code_hash(r: u32, ) -> Weight;
fn seal_reentrant_count(r: u32, ) -> Weight;
fn seal_account_reentrance_count(r: u32, ) -> Weight;
fn instr_i64const(r: u32, ) -> Weight;
fn instr_i64load(r: u32, ) -> Weight;
fn instr_i64store(r: u32, ) -> Weight;
@@ -1020,6 +1022,30 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
.saturating_add(T::DbWeight::get().writes(3 as u64))
.saturating_add(T::DbWeight::get().writes((150 as u64).saturating_mul(r as u64)))
}
// Storage: System Account (r:1 w:0)
// Storage: Contracts ContractInfoOf (r:1 w:1)
// Storage: Contracts CodeStorage (r:1 w:0)
// Storage: Timestamp Now (r:1 w:0)
/// The range of component `r` is `[0, 20]`.
fn seal_reentrant_count(r: u32, ) -> Weight {
Weight::from_ref_time(304_709_000 as u64)
// Standard Error: 67_000
.saturating_add(Weight::from_ref_time(15_411_000 as u64).saturating_mul(r as u64))
.saturating_add(T::DbWeight::get().reads(4 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: System Account (r:1 w:0)
// Storage: Contracts ContractInfoOf (r:1 w:1)
// Storage: Contracts CodeStorage (r:1 w:0)
// Storage: Timestamp Now (r:1 w:0)
/// The range of component `r` is `[0, 20]`.
fn seal_account_reentrance_count(r: u32, ) -> Weight {
Weight::from_ref_time(328_378_000 as u64)
// Standard Error: 137_000
.saturating_add(Weight::from_ref_time(37_448_000 as u64).saturating_mul(r as u64))
.saturating_add(T::DbWeight::get().reads(4 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
/// The range of component `r` is `[0, 50]`.
fn instr_i64const(r: u32, ) -> Weight {
// Minimum execution time: 69_022 nanoseconds.
@@ -2236,6 +2262,30 @@ impl WeightInfo for () {
.saturating_add(RocksDbWeight::get().writes(3 as u64))
.saturating_add(RocksDbWeight::get().writes((150 as u64).saturating_mul(r as u64)))
}
// Storage: System Account (r:1 w:0)
// Storage: Contracts ContractInfoOf (r:1 w:1)
// Storage: Contracts CodeStorage (r:1 w:0)
// Storage: Timestamp Now (r:1 w:0)
/// The range of component `r` is `[0, 20]`.
fn seal_reentrant_count(r: u32, ) -> Weight {
Weight::from_ref_time(304_709_000 as u64)
// Standard Error: 67_000
.saturating_add(Weight::from_ref_time(15_411_000 as u64).saturating_mul(r as u64))
.saturating_add(RocksDbWeight::get().reads(4 as u64))
.saturating_add(RocksDbWeight::get().writes(1 as u64))
}
// Storage: System Account (r:1 w:0)
// Storage: Contracts ContractInfoOf (r:1 w:1)
// Storage: Contracts CodeStorage (r:1 w:0)
// Storage: Timestamp Now (r:1 w:0)
/// The range of component `r` is `[0, 20]`.
fn seal_account_reentrance_count(r: u32, ) -> Weight {
Weight::from_ref_time(328_378_000 as u64)
// Standard Error: 137_000
.saturating_add(Weight::from_ref_time(37_448_000 as u64).saturating_mul(r as u64))
.saturating_add(RocksDbWeight::get().reads(4 as u64))
.saturating_add(RocksDbWeight::get().writes(1 as u64))
}
/// The range of component `r` is `[0, 50]`.
fn instr_i64const(r: u32, ) -> Weight {
// Minimum execution time: 69_022 nanoseconds.
@@ -2593,4 +2643,4 @@ impl WeightInfo for () {
// Standard Error: 986
.saturating_add(Weight::from_ref_time(1_867_001 as u64).saturating_mul(r as u64))
}
}
}