@@ -4,70 +4,121 @@ use crate::{
44        flashblocks:: { FlashblocksConfig ,  payload:: FlashblocksExtraCtx } , 
55    } , 
66    gas_limiter:: AddressGasLimiter , 
7+     metrics:: OpRBuilderMetrics , 
78    traits:: ClientBounds , 
89} ; 
910use  eyre:: WrapErr  as  _; 
10- use  reth_evm:: ConfigureEvm  as  _; 
11- use  reth_optimism_chainspec:: OpHardforks  as  _; 
11+ use  op_revm:: OpSpecId ; 
12+ use  reth_basic_payload_builder:: PayloadConfig ; 
13+ use  reth_evm:: { ConfigureEvm  as  _,  EvmEnv } ; 
14+ use  reth_optimism_chainspec:: { OpChainSpec ,  OpHardforks  as  _} ; 
1215use  reth_optimism_evm:: { OpEvmConfig ,  OpNextBlockEnvAttributes } ; 
13- use  reth_optimism_payload_builder:: OpPayloadBuilderAttributes ; 
16+ use  reth_optimism_payload_builder:: { OpPayloadBuilderAttributes ,  config:: OpDAConfig } ; 
17+ use  reth_optimism_primitives:: OpTransactionSigned ; 
1418use  reth_payload_primitives:: PayloadBuilderAttributes  as  _; 
19+ use  std:: sync:: Arc ; 
1520use  tokio_util:: sync:: CancellationToken ; 
1621
17- fn  get_op_payload_builder_ctx < Client > ( 
22+ #[ derive( Debug ) ]  
23+ pub ( super )  struct  OpPayloadSyncerCtx  { 
24+     /// The type that knows how to perform system calls and configure the evm. 
25+      pub  evm_config :  OpEvmConfig , 
26+     /// The DA config for the payload builder 
27+      pub  da_config :  OpDAConfig , 
28+     /// The chainspec 
29+      pub  chain_spec :  Arc < OpChainSpec > , 
30+     // /// How to build the payload. 
31+     // pub config: PayloadConfig<OpPayloadBuilderAttributes<OpTransactionSigned>>, 
32+     /// Block env attributes for the current block. 
33+      //pub block_env_attributes: OpNextBlockEnvAttributes, 
34+     /// Marker to check whether the job has been cancelled. 
35+      //pub cancel: CancellationToken, 
36+     /// Extra context for the payload builder 
37+      pub  extra_ctx :  FlashblocksExtraCtx , 
38+     /// Max gas that can be used by a transaction. 
39+      pub  max_gas_per_txn :  Option < u64 > , 
40+ } 
41+ 
42+ impl  OpPayloadSyncerCtx  { 
43+     pub ( super )  fn  into_op_payload_builder_ctx ( 
44+         self , 
45+         payload_config :  PayloadConfig < OpPayloadBuilderAttributes < OpTransactionSigned > > , 
46+         evm_env :  EvmEnv < OpSpecId > , 
47+         block_env_attributes :  OpNextBlockEnvAttributes , 
48+         cancel :  CancellationToken , 
49+         metrics :  Arc < OpRBuilderMetrics > , 
50+         address_gas_limiter :  AddressGasLimiter , 
51+     )  -> OpPayloadBuilderCtx  { 
52+         OpPayloadBuilderCtx  { 
53+             evm_config :  self . evm_config , 
54+             da_config :  self . da_config , 
55+             chain_spec :  self . chain_spec , 
56+             config :  payload_config, 
57+             evm_env, 
58+             block_env_attributes, 
59+             cancel, 
60+             builder_signer :  None , 
61+             metrics, 
62+             extra_ctx :  ( ) , 
63+             max_gas_per_txn :  self . max_gas_per_txn , 
64+             address_gas_limiter, 
65+         } 
66+     } 
67+ } 
68+ 
69+ pub ( super )  fn  get_op_payload_syncer_ctx < Client > ( 
1870    client :  Client , 
1971    evm_config :  OpEvmConfig , 
2072    builder_config :  BuilderConfig < FlashblocksConfig > , 
21-     address_gas_limiter :  AddressGasLimiter , 
22-     config :  reth_basic_payload_builder:: PayloadConfig < 
23-         OpPayloadBuilderAttributes < op_alloy_consensus:: OpTxEnvelope > , 
24-     > , 
25-     cancel :  CancellationToken , 
73+     // address_gas_limiter: AddressGasLimiter, 
74+     // config: reth_basic_payload_builder::PayloadConfig< 
75+     //     OpPayloadBuilderAttributes<op_alloy_consensus::OpTxEnvelope>, 
76+     // >, 
2677    extra_ctx :  FlashblocksExtraCtx , 
27- )  -> eyre :: Result < OpPayloadBuilderCtx < FlashblocksExtraCtx > > 
78+ )  -> OpPayloadSyncerCtx 
2879where 
2980    Client :  ClientBounds , 
3081{ 
3182    let  chain_spec = client. chain_spec ( ) ; 
32-     let  timestamp = config. attributes . timestamp ( ) ; 
33-     let  block_env_attributes = OpNextBlockEnvAttributes  { 
34-         timestamp, 
35-         suggested_fee_recipient :  config. attributes . suggested_fee_recipient ( ) , 
36-         prev_randao :  config. attributes . prev_randao ( ) , 
37-         gas_limit :  config
38-             . attributes 
39-             . gas_limit 
40-             . unwrap_or ( config. parent_header . gas_limit ) , 
41-         parent_beacon_block_root :  config
42-             . attributes 
43-             . payload_attributes 
44-             . parent_beacon_block_root , 
45-         extra_data :  if  chain_spec. is_holocene_active_at_timestamp ( timestamp)  { 
46-             config
47-                 . attributes 
48-                 . get_holocene_extra_data ( chain_spec. base_fee_params_at_timestamp ( timestamp) ) 
49-                 . wrap_err ( "failed to get holocene extra data for flashblocks payload builder" ) ?
50-         }  else  { 
51-             Default :: default ( ) 
52-         } , 
53-     } ; 
83+     //  let timestamp = config.attributes.timestamp();
84+     //  let block_env_attributes = OpNextBlockEnvAttributes {
85+     //      timestamp,
86+     //      suggested_fee_recipient: config.attributes.suggested_fee_recipient(),
87+     //      prev_randao: config.attributes.prev_randao(),
88+     //      gas_limit: config
89+     //          .attributes
90+     //          .gas_limit
91+     //          .unwrap_or(config.parent_header.gas_limit),
92+     //      parent_beacon_block_root: config
93+     //          .attributes
94+     //          .payload_attributes
95+     //          .parent_beacon_block_root,
96+     //      extra_data: if chain_spec.is_holocene_active_at_timestamp(timestamp) {
97+     //          config
98+     //              .attributes
99+     //              .get_holocene_extra_data(chain_spec.base_fee_params_at_timestamp(timestamp))
100+     //              .wrap_err("failed to get holocene extra data for flashblocks payload builder")?
101+     //      } else {
102+     //          Default::default()
103+     //      },
104+     //  };
54105
55-     let  evm_env = evm_config
56-         . next_evm_env ( & config. parent_header ,  & block_env_attributes) 
57-         . wrap_err ( "failed to create next evm env" ) ?; 
106+     //  let evm_env = evm_config
107+     //      .next_evm_env(&config.parent_header, &block_env_attributes)
108+     //      .wrap_err("failed to create next evm env")?;
58109
59-     Ok ( OpPayloadBuilderCtx :: < FlashblocksExtraCtx >  { 
110+     OpPayloadSyncerCtx  { 
60111        evm_config :  evm_config. clone ( ) , 
61-         chain_spec, 
62-         config, 
63-         evm_env, 
64-         block_env_attributes, 
65-         cancel, 
66112        da_config :  builder_config. da_config . clone ( ) , 
67-         builder_signer :  builder_config. builder_signer , 
68-         metrics :  Default :: default ( ) , 
113+         chain_spec, 
114+         //config, 
115+         // evm_env, 
116+         // block_env_attributes, 
117+         // cancel, 
118+         // builder_signer: builder_config.builder_signer, 
119+         // metrics: Default::default(), 
69120        extra_ctx, 
70121        max_gas_per_txn :  builder_config. max_gas_per_txn , 
71-         address_gas_limiter, 
72-     } ) 
122+         // address_gas_limiter,
123+     } 
73124} 
0 commit comments