use curr_time from new block

This commit is contained in:
Sergio Chouhy 2026-03-28 03:27:00 -03:00
parent b92dcbb711
commit 4f38dec019

View File

@ -16,6 +16,7 @@ use mempool::{MemPool, MemPoolHandle};
#[cfg(feature = "mock")] #[cfg(feature = "mock")]
pub use mock::SequencerCoreWithMockClients; pub use mock::SequencerCoreWithMockClients;
use nssa::V03State; use nssa::V03State;
use nssa_core::program::Timestamp;
pub use storage::error::DbError; pub use storage::error::DbError;
use testnet_initial_state::initial_state; use testnet_initial_state::initial_state;
@ -162,24 +163,20 @@ impl<BC: BlockSettlementClientTrait, IC: IndexerClientTrait> SequencerCore<BC, I
(sequencer_core, mempool_handle) (sequencer_core, mempool_handle)
} }
fn next_block_timestamp_ms() -> nssa_core::program::Timestamp {
u64::try_from(chrono::Utc::now().timestamp_millis()).expect("Timestamp must be positive")
}
fn execute_check_transaction_on_state( fn execute_check_transaction_on_state(
&mut self, &mut self,
tx: NSSATransaction, tx: NSSATransaction,
block_id: u64,
curr_time: Timestamp,
) -> Result<NSSATransaction, nssa::error::NssaError> { ) -> Result<NSSATransaction, nssa::error::NssaError> {
let block_id = self.next_block_id();
let timestamp_ms = Self::next_block_timestamp_ms();
match &tx { match &tx {
NSSATransaction::Public(tx) => { NSSATransaction::Public(tx) => {
self.state self.state
.transition_from_public_transaction(tx, block_id, timestamp_ms) .transition_from_public_transaction(tx, block_id, curr_time)
} }
NSSATransaction::PrivacyPreserving(tx) => self NSSATransaction::PrivacyPreserving(tx) => self
.state .state
.transition_from_privacy_preserving_transaction(tx, block_id, timestamp_ms), .transition_from_privacy_preserving_transaction(tx, block_id, curr_time),
NSSATransaction::ProgramDeployment(tx) => self NSSATransaction::ProgramDeployment(tx) => self
.state .state
.transition_from_program_deployment_transaction(tx), .transition_from_program_deployment_transaction(tx),
@ -256,7 +253,7 @@ impl<BC: BlockSettlementClientTrait, IC: IndexerClientTrait> SequencerCore<BC, I
break; break;
} }
match self.execute_check_transaction_on_state(tx) { match self.execute_check_transaction_on_state(tx, new_block_height, curr_time) {
Ok(valid_tx) => { Ok(valid_tx) => {
valid_transactions.push(valid_tx); valid_transactions.push(valid_tx);