seal_delegate_call api function (support for library contracts) (#10617)

* seal_call_code implementation

- tests
- benchmark

* Addressing @xgreenx's comments

* Fix test-linux-stable-int

* Rename seal_call_code to seal_delegate_call

* Pass value unchanged into lib contract

* Address @athei's comments

- whitespace .wat issues
- wrong/missing .wat comments
- redundant .wat calls/declarations

- change order of functions (seal_delegate_call right after seal_call)
  in decls, tests, benchmark
- fix comments, move doc comments to enum variants
- remove unnecessary empty lines

- rename runtime cost DelegateCall to DelegateCallBase
- do not set CallFlags::ALLOW_REENTRY for delegate_call

* Do not pass CallFlags::ALLOWS_REENTRY for delegate_call

* Update comment for seal_delegate_call and CallFlags

* Addressing @athei's comments (minor)

* Allow reentry for a new frame after delegate_call (revert)

* Same seal_caller and seal_value_transferred for lib contract

- test
- refactor frame args due to review
- logic for seal_caller (please review)

* Put caller on frame for delegate_call, minor fixes

* Update comment for delegate_call

* Addressing @athei's comments

* Update weights generated by benchmark

* Improve comments

* Address @HCastano's comments

* Update weights, thanks @joao-paulo-parity

* Improve InvalidCallFlags error comment
This commit is contained in:
Yarik Bratashchuk
2022-02-08 13:43:32 +02:00
committed by GitHub
parent 1d62516fad
commit d14e1c641e
10 changed files with 574 additions and 49 deletions
+23
View File
@@ -88,6 +88,7 @@ pub trait WeightInfo {
fn seal_take_storage_per_kb(n: u32, ) -> Weight;
fn seal_transfer(r: u32, ) -> Weight;
fn seal_call(r: u32, ) -> Weight;
fn seal_delegate_call(r: u32, ) -> Weight;
fn seal_call_per_transfer_input_output_kb(t: u32, i: u32, o: u32, ) -> Weight;
fn seal_instantiate(r: u32, ) -> Weight;
fn seal_instantiate_per_input_output_salt_kb(i: u32, o: u32, s: u32, ) -> Weight;
@@ -618,6 +619,17 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
.saturating_add(T::DbWeight::get().writes((100 as Weight).saturating_mul(r as Weight)))
}
// 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)
fn seal_delegate_call(r: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 11_788_000
.saturating_add((19_855_594_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads((99 as Weight).saturating_mul(r as Weight)))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: System Account (r:1 w:0)
// Storage: Contracts ContractInfoOf (r:101 w:101)
// Storage: Contracts CodeStorage (r:2 w:0)
// Storage: Timestamp Now (r:1 w:0)
@@ -1486,6 +1498,17 @@ impl WeightInfo for () {
.saturating_add(RocksDbWeight::get().writes((100 as Weight).saturating_mul(r as Weight)))
}
// 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)
fn seal_delegate_call(r: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 11_788_000
.saturating_add((19_855_594_000 as Weight).saturating_mul(r as Weight))
.saturating_add(RocksDbWeight::get().reads((99 as Weight).saturating_mul(r as Weight)))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
// Storage: System Account (r:1 w:0)
// Storage: Contracts ContractInfoOf (r:101 w:101)
// Storage: Contracts CodeStorage (r:2 w:0)
// Storage: Timestamp Now (r:1 w:0)