Skip to content

Commit 963830e

Browse files
authored
Merge pull request #192 from decipherhub/feat/validator-beneficiary
feat: set block beneficiary to proposer address
2 parents cbf3e2f + f6a21e3 commit 963830e

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

crates/execution/src/bridge.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl<S: BatchFetcher> ExecutionBridge<S> {
143143
parent_hash,
144144
gas_limit: 30_000_000,
145145
base_fee_per_gas: Some(1_000_000_000),
146-
beneficiary: Address::ZERO,
146+
beneficiary: cut.proposer_address.unwrap_or(Address::ZERO),
147147
})
148148
}
149149

@@ -199,7 +199,7 @@ impl<S: BatchFetcher> ExecutionBridge<S> {
199199
parent_hash,
200200
gas_limit,
201201
base_fee_per_gas,
202-
beneficiary: Address::ZERO,
202+
beneficiary: cut.proposer_address.unwrap_or(Address::ZERO),
203203
})
204204
}
205205
}

crates/node/src/node.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,6 @@ impl Node {
12971297
let epoch_config = EpochConfig::default();
12981298

12991299
// Block configuration from genesis
1300-
let beneficiary = self.beneficiary;
13011300
let gas_limit = self.gas_limit;
13021301

13031302
// Run the main event loop with graceful shutdown support
@@ -1315,7 +1314,6 @@ impl Node {
13151314
rpc_executor,
13161315
epoch_config,
13171316
self.epoch_block_reward,
1318-
beneficiary,
13191317
gas_limit,
13201318
)
13211319
.await;
@@ -1366,7 +1364,6 @@ impl Node {
13661364
rpc_executor: Option<Arc<cipherbft_rpc::EvmExecutionApi<InMemoryProvider>>>,
13671365
epoch_config: EpochConfig,
13681366
epoch_block_reward: U256,
1369-
beneficiary: [u8; 20],
13701367
gas_limit: u64,
13711368
) -> Result<()> {
13721369
loop {
@@ -1479,6 +1476,13 @@ impl Node {
14791476
// Execute Cut if execution layer is enabled
14801477
// Then store the block to MDBX for RPC queries
14811478
if let Some(ref bridge) = execution_bridge {
1479+
// Extract beneficiary from Cut BEFORE execute_cut consumes it
1480+
// The proposer_address is the Ethereum address of the validator who built this Cut
1481+
let block_beneficiary: [u8; 20] = cut
1482+
.proposer_address
1483+
.map(|addr| addr.into_array())
1484+
.unwrap_or([0u8; 20]);
1485+
14821486
match bridge.execute_cut(cut).await {
14831487
Ok(block_result) => {
14841488
info!(
@@ -1495,7 +1499,7 @@ impl Node {
14951499
// to prevent orphaned records referencing non-existent blocks.
14961500
if let Some(ref storage) = rpc_storage {
14971501
// Create and store the block FIRST
1498-
let block = Self::execution_result_to_block(height.0, &block_result, beneficiary, gas_limit);
1502+
let block = Self::execution_result_to_block(height.0, &block_result, block_beneficiary, gas_limit);
14991503
if let Err(e) = storage.block_store().put_block(&block).await {
15001504
error!("Failed to store block {} (hash: {}) to MDBX: {}", height.0, block_result.block_hash, e);
15011505
// Skip all related storage operations - don't create orphaned receipts/txs/logs

0 commit comments

Comments
 (0)