Skip to content

Commit 189c31a

Browse files
committed
Add extra metadata to block rewards
1 parent a6cb5af commit 189c31a

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

beacon_node/beacon_chain/src/block_reward.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{BeaconChain, BeaconChainError, BeaconChainTypes};
2-
use eth2::lighthouse::{AttestationRewards, BlockReward};
2+
use eth2::lighthouse::{AttestationRewards, BlockReward, BlockRewardMeta};
33
use operation_pool::{AttMaxCover, MaxCover};
44
use std::collections::HashMap;
55
use types::{BeaconBlockRef, BeaconState, EthSpec, Hash256, RelativeEpoch};
@@ -78,8 +78,16 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
7878
per_attestation_rewards,
7979
};
8080

81+
let meta = BlockRewardMeta {
82+
slot: block.slot(),
83+
parent_slot: state.latest_block_header().slot,
84+
proposer_index: block.proposer_index(),
85+
graffiti: block.body().graffiti().as_utf8_lossy(),
86+
};
87+
8188
Ok(BlockReward {
8289
block_root,
90+
meta,
8391
attestation_rewards,
8492
})
8593
}

common/eth2/src/lighthouse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use ssz::four_byte_option_impl;
1414
use ssz_derive::{Decode, Encode};
1515
use store::{AnchorInfo, Split};
1616

17-
pub use block_rewards::{AttestationRewards, BlockReward, BlockRewardsQuery};
17+
pub use block_rewards::{AttestationRewards, BlockReward, BlockRewardMeta, BlockRewardsQuery};
1818
pub use eth2_libp2p::{types::SyncState, PeerInfo};
1919

2020
// Define "legacy" implementations of `Option<T>` which use four bytes for encoding the union

common/eth2/src/lighthouse/block_rewards.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,20 @@ use types::{Hash256, Slot};
1212
pub struct BlockReward {
1313
/// Block root of the block that these rewards are for.
1414
pub block_root: Hash256,
15+
/// Metadata about the block, particularly reward-relevant metadata.
16+
pub meta: BlockRewardMeta,
1517
/// Rewards due to attestations.
1618
pub attestation_rewards: AttestationRewards,
1719
}
1820

21+
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
22+
pub struct BlockRewardMeta {
23+
pub slot: Slot,
24+
pub parent_slot: Slot,
25+
pub proposer_index: u64,
26+
pub graffiti: String,
27+
}
28+
1929
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
2030
pub struct AttestationRewards {
2131
/// Total block reward from attestations included.

0 commit comments

Comments
 (0)