1
- use revm_primitives:: Bytes ;
2
-
3
1
use super :: constants:: * ;
4
2
use crate :: {
5
- primitives:: {
6
- Address , SpecId ,
7
- SpecId :: { BERLIN , SPURIOUS_DRAGON , TANGERINE } ,
8
- U256 ,
9
- } ,
3
+ num_words,
4
+ primitives:: { Address , Bytes , SpecId , U256 } ,
10
5
SelfDestructResult ,
11
6
} ;
12
7
use std:: vec:: Vec ;
@@ -155,7 +150,7 @@ pub const fn keccak256_cost(len: u64) -> Option<u64> {
155
150
/// Calculate the cost of buffer per word.
156
151
#[ inline]
157
152
pub const fn cost_per_word ( len : u64 , multiple : u64 ) -> Option < u64 > {
158
- multiple. checked_mul ( len . div_ceil ( 32 ) )
153
+ multiple. checked_mul ( num_words ( len ) )
159
154
}
160
155
161
156
/// EIP-3860: Limit and meter initcode
@@ -302,9 +297,9 @@ pub const fn call_cost(
302
297
new_account_accounting : bool ,
303
298
) -> u64 {
304
299
// Account access.
305
- let mut gas = if spec_id. is_enabled_in ( BERLIN ) {
300
+ let mut gas = if spec_id. is_enabled_in ( SpecId :: BERLIN ) {
306
301
warm_cold_cost ( is_cold)
307
- } else if spec_id. is_enabled_in ( TANGERINE ) {
302
+ } else if spec_id. is_enabled_in ( SpecId :: TANGERINE ) {
308
303
// EIP-150: Gas cost changes for IO-heavy operations
309
304
700
310
305
} else {
@@ -319,7 +314,7 @@ pub const fn call_cost(
319
314
// new account cost
320
315
if new_account_accounting {
321
316
// EIP-161: State trie clearing (invariant-preserving alternative)
322
- if spec_id. is_enabled_in ( SPURIOUS_DRAGON ) {
317
+ if spec_id. is_enabled_in ( SpecId :: SPURIOUS_DRAGON ) {
323
318
// account only if there is value transferred.
324
319
if transfers_value {
325
320
gas += NEWACCOUNT ;
0 commit comments