Skip to content

Commit

Permalink
add configurable fee recipient back to PayloadBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobkaufmann committed Oct 11, 2024
1 parent 5b034d6 commit b1ce416
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
16 changes: 13 additions & 3 deletions mev-build-rs/src/payload/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use reth::{
proofs,
revm_primitives::{
alloy_primitives::{ChainId, Parity},
calc_excess_blob_gas, BlockEnv, CfgEnvWithHandlerCfg, TxEnv, TxKind, U256,
calc_excess_blob_gas, Address, BlockEnv, CfgEnvWithHandlerCfg, TxEnv, TxKind, U256,
},
transaction::FillTxEnv,
Block, BlockBody, Header, Receipt, Receipts, SealedBlock, Signature, Transaction,
Expand Down Expand Up @@ -213,6 +213,7 @@ impl Deref for PayloadBuilder {
pub struct Inner {
bids: Sender<EthBuiltPayload>,
signer: PrivateKeySigner,
fee_recipient: Address,
chain_id: ChainId,
execution_outcomes: Mutex<HashMap<PayloadId, ExecutionOutcome>>,
evm_config: EthEvmConfig,
Expand All @@ -222,12 +223,19 @@ impl PayloadBuilder {
pub fn new(
bids: Sender<EthBuiltPayload>,
signer: PrivateKeySigner,
fee_recipient: Address,
chain_id: ChainId,
chain_spec: Arc<ChainSpec>,
) -> Self {
let evm_config = EthEvmConfig::new(chain_spec);
let inner =
Inner { bids, signer, chain_id, execution_outcomes: Default::default(), evm_config };
let inner = Inner {
bids,
signer,
fee_recipient,
chain_id,
execution_outcomes: Default::default(),
evm_config,
};
Self(Arc::new(inner))
}

Expand All @@ -254,6 +262,8 @@ impl PayloadBuilder {
block_env.gas_limit = U256::from(gas_limit) - U256::from(BASE_TX_GAS_LIMIT);

block_env.coinbase = proposal_attributes.proposer_fee_recipient;
} else {
block_env.coinbase = self.0.fee_recipient;
}

(cfg_env, block_env)
Expand Down
14 changes: 11 additions & 3 deletions mev-build-rs/src/payload/service_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use reth::{
chainspec::ChainSpec,
cli::config::PayloadBuilderConfig,
payload::{EthBuiltPayload, PayloadBuilderHandle, PayloadBuilderService},
primitives::revm_primitives::Bytes,
primitives::revm_primitives::{Address, Bytes},
providers::CanonStateSubscriptions,
transaction_pool::TransactionPool,
};
Expand All @@ -27,6 +27,7 @@ fn signer_from_mnemonic(mnemonic: &str) -> Result<PrivateKeySigner, Error> {
pub struct PayloadServiceBuilder {
extra_data: Option<Bytes>,
signer: PrivateKeySigner,
fee_recipient: Address,
bid_tx: Sender<EthBuiltPayload>,
}

Expand All @@ -35,7 +36,8 @@ impl TryFrom<(&Config, Sender<EthBuiltPayload>)> for PayloadServiceBuilder {

fn try_from((value, bid_tx): (&Config, Sender<EthBuiltPayload>)) -> Result<Self, Self::Error> {
let signer = signer_from_mnemonic(&value.execution_mnemonic)?;
Ok(Self { extra_data: value.extra_data.clone(), signer, bid_tx })
let fee_recipient = value.fee_recipient.unwrap_or_else(|| signer.address());
Ok(Self { extra_data: value.extra_data.clone(), signer, fee_recipient, bid_tx })
}
}

Expand Down Expand Up @@ -73,7 +75,13 @@ where
pool,
ctx.task_executor().clone(),
payload_job_config,
PayloadBuilder::new(self.bid_tx, self.signer, chain_id, ctx.chain_spec().clone()),
PayloadBuilder::new(
self.bid_tx,
self.signer,
self.fee_recipient,
chain_id,
ctx.chain_spec().clone(),
),
);

let (payload_service, payload_builder) =
Expand Down

0 comments on commit b1ce416

Please sign in to comment.