@@ -24,115 +24,6 @@ type CurrencyOf<T> = <T as Config>::Currency;
24
24
25
25
benchmarks ! {
26
26
27
- runner_execute {
28
- // This benchmark tests the relationship between gas and weight. It deploys a contract which
29
- // has an infinite loop in a public function. We then call this function with varying amounts
30
- // of gas, expecting it to OOG. The benchmarking framework measures the amount of time (aka
31
- // weight) it takes before OOGing and relates that to the amount of gas provided, leaving us
32
- // with an estimate for gas-to-weight mapping.
33
-
34
- let x in 1 ..10000000 ;
35
-
36
- use rlp:: RlpStream ;
37
- use sp_core:: { H160 , U256 } ;
38
- use alloc:: vec;
39
-
40
- // contract bytecode below is for:
41
- //
42
- // pragma solidity >=0.8.0;
43
- //
44
- // contract InfiniteContractVar {
45
- // uint public count;
46
-
47
- // constructor() public {
48
- // count = 0;
49
- // }
50
-
51
- // function infinite() public {
52
- // while (true) {
53
- // count=count+1;
54
- // }
55
- // }
56
- // }
57
-
58
- let contract_bytecode = hex:: decode( concat!(
59
- "608060405234801561001057600080fd5b506000808190555061017c806100276000396000f3fe60" ,
60
- "8060405234801561001057600080fd5b50600436106100365760003560e01c806306661abd146100" ,
61
- "3b5780635bec9e6714610059575b600080fd5b610043610063565b604051610050919061009c565b" ,
62
- "60405180910390f35b610061610069565b005b60005481565b5b60011561008b5760016000546100" ,
63
- "8091906100b7565b60008190555061006a565b565b6100968161010d565b82525050565b60006020" ,
64
- "820190506100b1600083018461008d565b92915050565b60006100c28261010d565b91506100cd83" ,
65
- "61010d565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" ,
66
- "ff0382111561010257610101610117565b5b828201905092915050565b6000819050919050565b7f" ,
67
- "4e487b71000000000000000000000000000000000000000000000000000000006000526011600452" ,
68
- "60246000fdfea2646970667358221220bcab0385167dbed28dee34f1c5b30ecfcd67915495f0a32d" ,
69
- "2eeada8e094193a364736f6c63430008030033" ) )
70
- . expect( "Bad hex string" ) ;
71
-
72
- let caller = "1000000000000000000000000000000000000001" . parse:: <H160 >( ) . unwrap( ) ;
73
-
74
- let mut nonce: u64 = 1 ;
75
- let nonce_as_u256: U256 = nonce. into( ) ;
76
-
77
- let value = U256 :: default ( ) ;
78
- let gas_limit_create: u64 = 1000000 ;
79
- let is_transactional = true ;
80
- let validate = true ;
81
- let create_runner_results = T :: Runner :: create(
82
- caller,
83
- contract_bytecode,
84
- value,
85
- gas_limit_create,
86
- Some ( U256 :: from( 1_000_000_000 ) ) ,
87
- Some ( U256 :: from( 1_000_000_000 ) ) ,
88
- Some ( nonce_as_u256) ,
89
- Vec :: new( ) ,
90
- is_transactional,
91
- validate,
92
- None ,
93
- None ,
94
- T :: config( ) ,
95
- ) ;
96
- assert!( create_runner_results. is_ok( ) , "create() failed" ) ;
97
-
98
- // derive the resulting contract address from our create
99
- let mut rlp = RlpStream :: new_list( 2 ) ;
100
- rlp. append( & caller) ;
101
- rlp. append( & 0u8 ) ;
102
- let contract_address = H160 :: from_slice( & sp_io:: hashing:: keccak_256( & rlp. out( ) ) [ 12 ..] ) ;
103
-
104
- // derive encoded contract call -- in this case, just the function selector
105
- let mut encoded_call = vec![ 0u8 ; 4 ] ;
106
- encoded_call[ 0 ..4 ] . copy_from_slice( & sp_io:: hashing:: keccak_256( b"infinite()" ) [ 0 ..4 ] ) ;
107
-
108
- let gas_limit_call = gas_limit_create;
109
-
110
- } : {
111
-
112
- nonce += 1 ;
113
- let nonce_as_u256: U256 = nonce. into( ) ;
114
-
115
- let is_transactional = true ;
116
- let validate = true ;
117
- let call_runner_results = T :: Runner :: call(
118
- caller,
119
- contract_address,
120
- encoded_call,
121
- value,
122
- gas_limit_call,
123
- Some ( U256 :: from( 1_000_000_000 ) ) ,
124
- Some ( U256 :: from( 1_000_000_000 ) ) ,
125
- Some ( nonce_as_u256) ,
126
- Vec :: new( ) ,
127
- is_transactional,
128
- validate,
129
- None ,
130
- None ,
131
- T :: config( ) ,
132
- ) ;
133
- assert!( call_runner_results. is_ok( ) , "call() failed" ) ;
134
- }
135
-
136
27
withdraw {
137
28
let caller = frame_benchmarking:: whitelisted_caller:: <T :: AccountId >( ) ;
138
29
let from = H160 :: from_low_u64_le( 0 ) ;
0 commit comments