@@ -256,6 +256,7 @@ impl Env {
256
256
}
257
257
}
258
258
259
+
259
260
/// EVM configuration.
260
261
#[ derive( Clone , Debug , Eq , PartialEq , Hash ) ]
261
262
#[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
@@ -464,18 +465,6 @@ pub struct BlockEnv {
464
465
pub blob_excess_gas_and_price : Option < BlobExcessGasAndPrice > ,
465
466
}
466
467
467
- /// Structure holding block blob excess gas and it calculates blob fee.
468
- ///
469
- /// Incorporated as part of the Cancun upgrade via [EIP-4844].
470
- ///
471
- /// [EIP-4844]: https://eips.ethereum.org/EIPS/eip-4844
472
- #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
473
- #[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
474
- pub struct BlobExcessGasAndPrice {
475
- pub excess_blob_gas : u64 ,
476
- pub blob_gasprice : u128 ,
477
- }
478
-
479
468
impl BlobExcessGasAndPrice {
480
469
/// Takes excess blob gas and calculated blob fee with [`calc_blob_fee`]
481
470
pub fn new ( excess_blob_gas : u64 ) -> Self {
@@ -487,23 +476,6 @@ impl BlobExcessGasAndPrice {
487
476
}
488
477
}
489
478
490
- #[ cfg( all( feature = "optimism" , not( feature = "taiko" ) ) ) ]
491
- #[ derive( Clone , Debug , Default , PartialEq , Eq , Hash ) ]
492
- #[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
493
- pub struct OptimismFields {
494
- pub source_hash : Option < B256 > ,
495
- pub mint : Option < u128 > ,
496
- pub is_system_transaction : Option < bool > ,
497
- /// An enveloped EIP-2718 typed transaction. This is used
498
- /// to compute the L1 tx cost using the L1 block info, as
499
- /// opposed to requiring downstream apps to compute the cost
500
- /// externally.
501
- /// This field is optional to allow the [TxEnv] to be constructed
502
- /// for non-optimism chains when the `optimism` feature is enabled,
503
- /// but the [CfgEnv] `optimism` field is set to false.
504
- pub enveloped_tx : Option < Bytes > ,
505
- }
506
-
507
479
#[ cfg( all( feature = "taiko" , not( feature = "optimism" ) ) ) ]
508
480
#[ derive( Clone , Debug , Default , PartialEq , Eq , Hash ) ]
509
481
#[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
@@ -644,6 +616,65 @@ impl TxEnv {
644
616
}
645
617
}
646
618
619
+ /// Structure holding block blob excess gas and it calculates blob fee.
620
+ ///
621
+ /// Incorporated as part of the Cancun upgrade via [EIP-4844].
622
+ ///
623
+ /// [EIP-4844]: https://eips.ethereum.org/EIPS/eip-4844
624
+ #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
625
+ #[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
626
+ pub struct BlobExcessGasAndPrice {
627
+ /// The excess blob gas of the block.
628
+ pub excess_blob_gas : u64 ,
629
+ /// The calculated blob gas price based on the `excess_blob_gas`, See [calc_blob_gasprice]
630
+ pub blob_gasprice : u128 ,
631
+ }
632
+
633
+ impl BlobExcessGasAndPrice {
634
+ /// Creates a new instance by calculating the blob gas price with [`calc_blob_gasprice`].
635
+ pub fn new ( excess_blob_gas : u64 ) -> Self {
636
+ let blob_gasprice = calc_blob_gasprice ( excess_blob_gas) ;
637
+ Self {
638
+ excess_blob_gas,
639
+ blob_gasprice,
640
+ }
641
+ }
642
+ }
643
+
644
+ /// Additional [TxEnv] fields for optimism.
645
+ #[ cfg( feature = "optimism" ) ]
646
+ #[ derive( Clone , Debug , Default , PartialEq , Eq , Hash ) ]
647
+ #[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
648
+ pub struct OptimismFields {
649
+ /// The source hash is used to make sure that deposit transactions do
650
+ /// not have identical hashes.
651
+ ///
652
+ /// L1 originated deposit transaction source hashes are computed using
653
+ /// the hash of the l1 block hash and the l1 log index.
654
+ /// L1 attributes deposit source hashes are computed with the l1 block
655
+ /// hash and the sequence number = l2 block number - l2 epoch start
656
+ /// block number.
657
+ ///
658
+ /// These two deposit transaction sources specify a domain in the outer
659
+ /// hash so there are no collisions.
660
+ pub source_hash : Option < B256 > ,
661
+ /// The amount to increase the balance of the `from` account as part of
662
+ /// a deposit transaction. This is unconditional and is applied to the
663
+ /// `from` account even if the deposit transaction fails since
664
+ /// the deposit is pre-paid on L1.
665
+ pub mint : Option < u128 > ,
666
+ /// Whether or not the transaction is a system transaction.
667
+ pub is_system_transaction : Option < bool > ,
668
+ /// An enveloped EIP-2718 typed transaction. This is used
669
+ /// to compute the L1 tx cost using the L1 block info, as
670
+ /// opposed to requiring downstream apps to compute the cost
671
+ /// externally.
672
+ /// This field is optional to allow the [TxEnv] to be constructed
673
+ /// for non-optimism chains when the `optimism` feature is enabled,
674
+ /// but the [CfgEnv] `optimism` field is set to false.
675
+ pub enveloped_tx : Option < Bytes > ,
676
+ }
677
+
647
678
impl Default for TxEnv {
648
679
fn default ( ) -> Self {
649
680
Self {
0 commit comments