Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion crates/indexer/engine/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,9 @@ impl<P: Provider + Send + Sync + Clone + std::fmt::Debug + 'static> Engine<P> {

// Store receipt if available
if let Some(receipt) = receipt {
self.storage.store_transaction_receipt(receipt).await?;
self.storage
.store_transaction_receipt(receipt, block_timestamp)
.await?;
}

Ok(())
Expand Down
4 changes: 3 additions & 1 deletion crates/migrations/20251124215151_transaction_receipts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ CREATE TABLE transaction_receipts (
execution_resources TEXT NOT NULL,
block_hash TEXT,
block_number INTEGER NOT NULL,
block_timestamp INTEGER NOT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
UNIQUE (transaction_hash)
);

CREATE INDEX idx_transaction_receipts_block_number ON transaction_receipts(block_number);
CREATE INDEX idx_transaction_receipts_block_number ON transaction_receipts(block_number);
CREATE INDEX idx_transaction_receipts_block_timestamp ON transaction_receipts(block_timestamp);
9 changes: 6 additions & 3 deletions crates/sqlite/sqlite/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2205,6 +2205,7 @@ impl Storage for Sql {
async fn store_transaction_receipt(
&self,
receipt_with_block: &starknet::core::types::TransactionReceiptWithBlockInfo,
block_timestamp: u64,
) -> Result<(), StorageError> {
use starknet::core::types::{ExecutionResult, ReceiptBlock, TransactionReceipt};

Expand Down Expand Up @@ -2275,8 +2276,8 @@ impl Storage for Sql {
self.executor
.send(QueryMessage::other(
"INSERT INTO transaction_receipts (id, transaction_hash, actual_fee_amount, actual_fee_unit, \
execution_status, finality_status, revert_reason, execution_resources, block_hash, block_number) \
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) \
execution_status, finality_status, revert_reason, execution_resources, block_hash, block_number, block_timestamp) \
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) \
ON CONFLICT(transaction_hash) DO UPDATE SET \
actual_fee_amount=excluded.actual_fee_amount, \
actual_fee_unit=excluded.actual_fee_unit, \
Expand All @@ -2285,7 +2286,8 @@ impl Storage for Sql {
revert_reason=excluded.revert_reason, \
execution_resources=excluded.execution_resources, \
block_hash=excluded.block_hash, \
block_number=excluded.block_number \
block_number=excluded.block_number, \
block_timestamp=excluded.block_timestamp \
RETURNING *"
.to_string(),
vec![
Expand All @@ -2299,6 +2301,7 @@ impl Storage for Sql {
Argument::String(execution_resources_json),
Argument::String(block_hash.unwrap_or_default()),
Argument::String(block_number.to_string()),
Argument::String(block_timestamp.to_string()),
],
))
.map_err(|e| {
Expand Down
1 change: 1 addition & 0 deletions crates/storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ pub trait Storage: ReadOnlyStorage + Send + Sync + Debug {
async fn store_transaction_receipt(
&self,
receipt: &starknet::core::types::TransactionReceiptWithBlockInfo,
block_timestamp: u64,
) -> Result<(), StorageError>;

/// Stores an event with the storage.
Expand Down
Loading