@@ -33,8 +33,12 @@ pub const PHAROS_CONSENSUS_ID: [u8; 4] = *b"PHAR";
3333/// Mainnet epoch length in seconds (4 hours)
3434pub const MAINNET_EPOCH_LENGTH_SECS : u64 = 4 * 60 * 60 ; // 14400 seconds
3535
36- /// Testnet (Atlantic) epoch length in seconds.
37- pub const TESTNET_EPOCH_LENGTH_SECS : u64 = 7828 ;
36+ /// Testnet (Atlantic) epoch length in seconds (30 minutes).
37+ pub const TESTNET_EPOCH_LENGTH_SECS : u64 = 30 * 60 ; // 1800 seconds
38+
39+ /// Storage slot index for `currentEpoch` on the Pharos staking precompile.
40+ /// This stores the current epoch **number** (increments every epoch duration).
41+ pub const CURRENT_EPOCH_SLOT : u64 = 5 ;
3842
3943/// Pharos Mainnet chain ID
4044pub const PHAROS_MAINNET_CHAIN_ID : u32 = 688600 ;
@@ -46,13 +50,18 @@ pub const PHAROS_ATLANTIC_CHAIN_ID: u32 = 688689;
4650pub const DEFAULT_WITHDRAW_WINDOW_EPOCHS : u64 = 84 ;
4751
4852/// Configuration trait for Pharos network parameters.
53+ ///
54+ /// Pharos epochs are **time-based** (not block-count-based). The epoch number
55+ /// is stored on-chain at slot 5 of the staking precompile and increments every
56+ /// `EPOCH_LENGTH_SECS` seconds. There is no fixed number of blocks per epoch.
57+ ///
58+ /// Epoch determination requires either:
59+ /// - Reading `currentEpoch` from the staking contract (off-chain prover)
60+ /// - Verifying a storage proof of slot 5 against the block's state root (on-chain verifier)
4961pub trait Config : Clone + Send + Sync {
5062 /// The epoch length in seconds
5163 const EPOCH_LENGTH_SECS : u64 ;
5264
53- /// The epoch length in blocks (derived from epoch length and block time)
54- const EPOCH_LENGTH_BLOCKS : u64 ;
55-
5665 /// The chain ID for this network
5766 const CHAIN_ID : u64 ;
5867
@@ -62,27 +71,6 @@ pub trait Config: Clone + Send + Sync {
6271 /// The unstaking period in seconds (withdraw_window_epochs × epoch_length_secs).
6372 /// Defaults to `DEFAULT_WITHDRAW_WINDOW_EPOCHS × EPOCH_LENGTH_SECS`.
6473 const UNBONDING_PERIOD : u64 = DEFAULT_WITHDRAW_WINDOW_EPOCHS * Self :: EPOCH_LENGTH_SECS ;
65-
66- /// Calculate the epoch number for a given block number
67- fn compute_epoch ( block_number : u64 ) -> u64 {
68- block_number / Self :: EPOCH_LENGTH_BLOCKS
69- }
70-
71- /// Check if a block is an epoch boundary block (last block of an epoch).
72- ///
73- /// The epoch boundary is defined as the last block of an epoch, i.e.,
74- /// `(block_number + 1) % epoch_length == 0`.
75- ///
76- /// At epoch boundaries, the validator set for the next epoch is finalized
77- fn is_epoch_boundary ( block_number : u64 ) -> bool {
78- ( block_number + 1 ) % Self :: EPOCH_LENGTH_BLOCKS == 0
79- }
80-
81- /// Get the first block number of the next epoch
82- fn next_epoch_start ( current_block : u64 ) -> u64 {
83- let current_epoch = Self :: compute_epoch ( current_block) ;
84- ( current_epoch + 1 ) * Self :: EPOCH_LENGTH_BLOCKS
85- }
8674}
8775
8876/// Pharos Mainnet configuration
@@ -93,12 +81,6 @@ impl Config for Mainnet {
9381 /// 4 hours epoch length
9482 const EPOCH_LENGTH_SECS : u64 = MAINNET_EPOCH_LENGTH_SECS ;
9583
96- /// With ~1 second finality (sub-second), assuming 1 block per second
97- /// 4 hours = 14400 blocks
98- const EPOCH_LENGTH_BLOCKS : u64 = 14400 ;
99-
100- /// Mainnet chain ID - TBD
101- /// Placeholder based on testnet pattern
10284 const CHAIN_ID : u64 = 688600 ;
10385
10486 const ID : [ u8 ; 4 ] = PHAROS_CONSENSUS_ID ;
@@ -109,11 +91,9 @@ impl Config for Mainnet {
10991pub struct Testnet ;
11092
11193impl Config for Testnet {
112- /// ~93.8 minutes epoch length
94+ /// 30 minutes epoch length
11395 const EPOCH_LENGTH_SECS : u64 = TESTNET_EPOCH_LENGTH_SECS ;
11496
115- const EPOCH_LENGTH_BLOCKS : u64 = 7828 ;
116-
11797 /// Pharos Testnet chain ID
11898 const CHAIN_ID : u64 = 688689 ;
11999
0 commit comments