mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(revm): Integrate State (#3512)
Co-authored-by: Roman Krasiuk <rokrassyuk@gmail.com> Co-authored-by: Alexey Shekhirin <a.shekhirin@gmail.com> Co-authored-by: Dan Cline <6798349+Rjected@users.noreply.github.com> Co-authored-by: Bjerg <onbjerg@users.noreply.github.com>
This commit is contained in:
@ -61,7 +61,7 @@ pub fn base_block_reward(
|
||||
/// // The base block reward is 5 ETH, and the ommer inclusion reward is 1/32th of 5 ETH.
|
||||
/// assert_eq!(
|
||||
/// reward.unwrap(),
|
||||
/// U256::from(ETH_TO_WEI * 5 + ((ETH_TO_WEI * 5) >> 5))
|
||||
/// ETH_TO_WEI * 5 + ((ETH_TO_WEI * 5) >> 5)
|
||||
/// );
|
||||
/// ```
|
||||
///
|
||||
@ -70,8 +70,8 @@ pub fn base_block_reward(
|
||||
/// - Definition: [Yellow Paper][yp] (page 15, 11.3)
|
||||
///
|
||||
/// [yp]: https://ethereum.github.io/yellowpaper/paper.pdf
|
||||
pub fn block_reward(base_block_reward: u128, ommers: usize) -> U256 {
|
||||
U256::from(base_block_reward + (base_block_reward >> 5) * ommers as u128)
|
||||
pub fn block_reward(base_block_reward: u128, ommers: usize) -> u128 {
|
||||
base_block_reward + (base_block_reward >> 5) * ommers as u128
|
||||
}
|
||||
|
||||
/// Calculate the reward for an ommer.
|
||||
@ -98,8 +98,8 @@ pub fn ommer_reward(
|
||||
base_block_reward: u128,
|
||||
block_number: BlockNumber,
|
||||
ommer_block_number: BlockNumber,
|
||||
) -> U256 {
|
||||
U256::from(((8 + ommer_block_number - block_number) as u128 * base_block_reward) >> 3)
|
||||
) -> u128 {
|
||||
((8 + ommer_block_number - block_number) as u128 * base_block_reward) >> 3
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@ -139,7 +139,7 @@ mod tests {
|
||||
];
|
||||
|
||||
for (num_ommers, expected_reward) in cases {
|
||||
assert_eq!(block_reward(base_reward, num_ommers), U256::from(expected_reward));
|
||||
assert_eq!(block_reward(base_reward, num_ommers), expected_reward);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user