1use alloy_evm::env::BlockEnvironment;
2use alloy_primitives::{Address, B256, U256, uint};
3use revm::{
4 context::{Block, BlockEnv},
5 context_interface::block::BlobExcessGasAndPrice,
6};
7
8#[derive(Debug, Clone, Default, derive_more::Deref, derive_more::DerefMut)]
10pub struct TempoBlockEnv {
11 #[deref]
13 #[deref_mut]
14 pub inner: BlockEnv,
15
16 pub timestamp_millis_part: u64,
18}
19
20impl TempoBlockEnv {
21 pub fn timestamp_millis(&self) -> U256 {
23 self.inner
24 .timestamp
25 .saturating_mul(uint!(1000_U256))
26 .saturating_add(U256::from(self.timestamp_millis_part))
27 }
28}
29
30impl Block for TempoBlockEnv {
31 #[inline]
32 fn number(&self) -> U256 {
33 self.inner.number()
34 }
35
36 #[inline]
37 fn beneficiary(&self) -> Address {
38 self.inner.beneficiary()
39 }
40
41 #[inline]
42 fn timestamp(&self) -> U256 {
43 self.inner.timestamp()
44 }
45
46 #[inline]
47 fn gas_limit(&self) -> u64 {
48 self.inner.gas_limit()
49 }
50
51 #[inline]
52 fn basefee(&self) -> u64 {
53 self.inner.basefee()
54 }
55
56 #[inline]
57 fn difficulty(&self) -> U256 {
58 self.inner.difficulty()
59 }
60
61 #[inline]
62 fn prevrandao(&self) -> Option<B256> {
63 self.inner.prevrandao()
64 }
65
66 #[inline]
67 fn blob_excess_gas_and_price(&self) -> Option<BlobExcessGasAndPrice> {
68 self.inner.blob_excess_gas_and_price()
69 }
70}
71
72impl BlockEnvironment for TempoBlockEnv {
73 fn inner_mut(&mut self) -> &mut BlockEnv {
74 &mut self.inner
75 }
76}