@@ -340,41 +340,13 @@ macro_rules! impl_runtime_apis_plus_common {
340
340
let without_base_extrinsic_weight = true ;
341
341
342
342
343
- // Estimated encoded transaction size must be based on the transaction
344
- // type (TransactionData) to be compatible with all transaction types.
345
- // TODO: remove, since we will get rid of base_cost
346
- let mut estimated_transaction_len = data. len( ) +
347
- // pallet ethereum index: 1
348
- // transact call index: 1
349
- // Transaction enum variant: 1
350
- // chain_id 9 bytes (some varient)
351
- // nonce: 32
352
- // max_priority_fee_per_gas: 33 (some varient)
353
- // max_fee_per_gas: 33 (some varient)
354
- // gas_price: 1 (none varient)
355
- // gas_limit: 32
356
- // action: 21 (enum varianrt + call address)
357
- // value: 32
358
- // access_list: 1 (empty vec size)
359
- // 65 bytes signature
360
- 261 ;
361
-
362
- if access_list. is_some( ) {
363
- estimated_transaction_len += access_list. encoded_size( ) ;
364
- }
365
-
366
- let gas_limit = gas_limit. min( u64 :: MAX . into( ) ) . low_u64( ) ;
367
-
368
- let ( weight_limit, proof_size_base_cost) =
369
- match <Runtime as pallet_evm:: Config >:: GasWeightMapping :: gas_to_weight(
370
- gas_limit,
371
- without_base_extrinsic_weight
372
- ) {
373
- weight_limit if weight_limit. proof_size( ) > 0 => {
374
- ( Some ( weight_limit) , Some ( estimated_transaction_len as u64 ) )
375
- }
376
- _ => ( None , None ) ,
377
- } ;
343
+ let gas_limit = if gas_limit > U256 :: from( u64 :: MAX ) {
344
+ u64 :: MAX
345
+ } else {
346
+ gas_limit. low_u64( )
347
+ } ;
348
+ let weight_limit = <Runtime as pallet_evm:: Config >:: GasWeightMapping :: gas_to_weight( gas_limit, true ) ;
349
+ let proof_size_pre_execution = cumulus_primitives_storage_weight_reclaim:: get_proof_size( ) . unwrap_or_default( ) ;
378
350
379
351
let _ = <Runtime as pallet_evm:: Config >:: Runner :: call(
380
352
from,
@@ -388,8 +360,8 @@ macro_rules! impl_runtime_apis_plus_common {
388
360
access_list. unwrap_or_default( ) ,
389
361
is_transactional,
390
362
validate,
391
- weight_limit,
392
- proof_size_base_cost ,
363
+ Some ( weight_limit) ,
364
+ proof_size_pre_execution ,
393
365
<Runtime as pallet_evm:: Config >:: config( ) ,
394
366
) ;
395
367
} ) ;
@@ -477,42 +449,13 @@ macro_rules! impl_runtime_apis_plus_common {
477
449
let is_transactional = false ;
478
450
let validate = true ;
479
451
480
- // Estimated encoded transaction size must be based on the transaction
481
- // type (TransactionData) to be compatible with all transaction types.
482
- // TODO: remove, since we will get rid of base_cost
483
- let mut estimated_transaction_len = data. len( ) +
484
- // pallet ethereum index: 1
485
- // transact call index: 1
486
- // Transaction enum variant: 1
487
- // chain_id 9 bytes (some varient)
488
- // nonce: 32
489
- // max_priority_fee_per_gas: 33 (some varient)
490
- // max_fee_per_gas: 33 (some varient)
491
- // gas_price: 1 (none varient)
492
- // gas_limit: 32
493
- // action: 21 (enum varianrt + call address)
494
- // value: 32
495
- // access_list: 1 (empty vec size)
496
- // 65 bytes signature
497
- 261 ;
498
-
499
- if access_list. is_some( ) {
500
- estimated_transaction_len += access_list. encoded_size( ) ;
501
- }
502
-
503
- let gas_limit = gas_limit. min( u64 :: MAX . into( ) ) . low_u64( ) ;
504
- let without_base_extrinsic_weight = true ;
505
-
506
- let ( weight_limit, proof_size_base_cost) =
507
- match <Runtime as pallet_evm:: Config >:: GasWeightMapping :: gas_to_weight(
508
- gas_limit,
509
- without_base_extrinsic_weight
510
- ) {
511
- weight_limit if weight_limit. proof_size( ) > 0 => {
512
- ( Some ( weight_limit) , Some ( estimated_transaction_len as u64 ) )
513
- }
514
- _ => ( None , None ) ,
515
- } ;
452
+ let gas_limit = if gas_limit > U256 :: from( u64 :: MAX ) {
453
+ u64 :: MAX
454
+ } else {
455
+ gas_limit. low_u64( )
456
+ } ;
457
+ let weight_limit = <Runtime as pallet_evm:: Config >:: GasWeightMapping :: gas_to_weight( gas_limit, true ) ;
458
+ let proof_size_pre_execution = cumulus_primitives_storage_weight_reclaim:: get_proof_size( ) . unwrap_or_default( ) ;
516
459
517
460
<Runtime as pallet_evm:: Config >:: Runner :: call(
518
461
from,
@@ -526,8 +469,8 @@ macro_rules! impl_runtime_apis_plus_common {
526
469
access_list. unwrap_or_default( ) ,
527
470
is_transactional,
528
471
validate,
529
- weight_limit,
530
- proof_size_base_cost ,
472
+ Some ( weight_limit) ,
473
+ proof_size_pre_execution ,
531
474
config. as_ref( ) . unwrap_or( <Runtime as pallet_evm:: Config >:: config( ) ) ,
532
475
) . map_err( |err| err. error. into( ) )
533
476
}
@@ -553,43 +496,14 @@ macro_rules! impl_runtime_apis_plus_common {
553
496
let is_transactional = false ;
554
497
let validate = true ;
555
498
556
- let mut estimated_transaction_len = data. len( ) +
557
- // from: 20
558
- // value: 32
559
- // gas_limit: 32
560
- // nonce: 32
561
- // 1 byte transaction action variant
562
- // chain id 8 bytes
563
- // 65 bytes signature
564
- 190 ;
565
-
566
- if max_fee_per_gas. is_some( ) {
567
- estimated_transaction_len += 32 ;
568
- }
569
- if max_priority_fee_per_gas. is_some( ) {
570
- estimated_transaction_len += 32 ;
571
- }
572
- if access_list. is_some( ) {
573
- estimated_transaction_len += access_list. encoded_size( ) ;
574
- }
575
-
576
499
let gas_limit = if gas_limit > U256 :: from( u64 :: MAX ) {
577
500
u64 :: MAX
578
501
} else {
579
502
gas_limit. low_u64( )
580
503
} ;
581
- let without_base_extrinsic_weight = true ;
582
504
583
- let ( weight_limit, proof_size_base_cost) =
584
- match <Runtime as pallet_evm:: Config >:: GasWeightMapping :: gas_to_weight(
585
- gas_limit,
586
- without_base_extrinsic_weight
587
- ) {
588
- weight_limit if weight_limit. proof_size( ) > 0 => {
589
- ( Some ( weight_limit) , Some ( estimated_transaction_len as u64 ) )
590
- }
591
- _ => ( None , None ) ,
592
- } ;
505
+ let weight_limit = <Runtime as pallet_evm:: Config >:: GasWeightMapping :: gas_to_weight( gas_limit, true ) ;
506
+ let proof_size_pre_execution = cumulus_primitives_storage_weight_reclaim:: get_proof_size( ) . unwrap_or_default( ) ;
593
507
594
508
#[ allow( clippy:: or_fun_call) ] // suggestion not helpful here
595
509
<Runtime as pallet_evm:: Config >:: Runner :: create(
@@ -603,8 +517,8 @@ macro_rules! impl_runtime_apis_plus_common {
603
517
access_list. unwrap_or_default( ) ,
604
518
is_transactional,
605
519
validate,
606
- weight_limit,
607
- proof_size_base_cost ,
520
+ Some ( weight_limit) ,
521
+ proof_size_pre_execution ,
608
522
config. as_ref( ) . unwrap_or( <Runtime as pallet_evm:: Config >:: config( ) ) ,
609
523
) . map_err( |err| err. error. into( ) )
610
524
}
0 commit comments