@@ -161,23 +161,29 @@ impl BlockHeaderInfo {
161
161
/// Block economics config taken from genesis config
162
162
pub struct BlockEconomicsConfig {
163
163
gas_price_adjustment_rate : Rational32 ,
164
- min_gas_price : Balance ,
165
- max_gas_price : Balance ,
164
+ genesis_min_gas_price : Balance ,
165
+ genesis_max_gas_price : Balance ,
166
166
genesis_protocol_version : ProtocolVersion ,
167
167
}
168
168
169
169
impl BlockEconomicsConfig {
170
170
/// Set max gas price to be this multiplier * min_gas_price
171
171
const MAX_GAS_MULTIPLIER : u128 = 20 ;
172
172
/// Compute min gas price according to protocol version and genesis protocol version.
173
+ ///
174
+ /// This returns the effective minimum gas price for a block with the given
175
+ /// protocol version. The base value is defined in genesis.config but has
176
+ /// been overwritten at specific protocol versions. Chains with a genesis
177
+ /// version higher than those changes are not overwritten and will instead
178
+ /// respect the value defined in genesis.
173
179
pub fn min_gas_price ( & self , protocol_version : ProtocolVersion ) -> Balance {
174
180
if self . genesis_protocol_version < MIN_PROTOCOL_VERSION_NEP_92 {
175
181
if protocol_version >= MIN_PROTOCOL_VERSION_NEP_92_FIX {
176
182
MIN_GAS_PRICE_NEP_92_FIX
177
183
} else if protocol_version >= MIN_PROTOCOL_VERSION_NEP_92 {
178
184
MIN_GAS_PRICE_NEP_92
179
185
} else {
180
- self . min_gas_price
186
+ self . genesis_min_gas_price
181
187
}
182
188
} else if self . genesis_protocol_version < MIN_PROTOCOL_VERSION_NEP_92_FIX {
183
189
if protocol_version >= MIN_PROTOCOL_VERSION_NEP_92_FIX {
@@ -186,18 +192,18 @@ impl BlockEconomicsConfig {
186
192
MIN_GAS_PRICE_NEP_92
187
193
}
188
194
} else {
189
- self . min_gas_price
195
+ self . genesis_min_gas_price
190
196
}
191
197
}
192
198
193
199
pub fn max_gas_price ( & self , protocol_version : ProtocolVersion ) -> Balance {
194
200
if checked_feature ! ( "stable" , CapMaxGasPrice , protocol_version) {
195
201
std:: cmp:: min (
196
- self . max_gas_price ,
202
+ self . genesis_max_gas_price ,
197
203
Self :: MAX_GAS_MULTIPLIER * self . min_gas_price ( protocol_version) ,
198
204
)
199
205
} else {
200
- self . max_gas_price
206
+ self . genesis_max_gas_price
201
207
}
202
208
}
203
209
@@ -210,8 +216,8 @@ impl From<&ChainGenesis> for BlockEconomicsConfig {
210
216
fn from ( chain_genesis : & ChainGenesis ) -> Self {
211
217
BlockEconomicsConfig {
212
218
gas_price_adjustment_rate : chain_genesis. gas_price_adjustment_rate ,
213
- min_gas_price : chain_genesis. min_gas_price ,
214
- max_gas_price : chain_genesis. max_gas_price ,
219
+ genesis_min_gas_price : chain_genesis. min_gas_price ,
220
+ genesis_max_gas_price : chain_genesis. max_gas_price ,
215
221
genesis_protocol_version : chain_genesis. protocol_version ,
216
222
}
217
223
}
0 commit comments