Commit 38e4684a authored by Hamdi Allam's avatar Hamdi Allam Committed by GitHub

fix(indexer): L1/L2 independent resyncing (#8735)

* allow l1 & l2 to be re-synced independently

* sent_message should cascade the delete

* nit
parent 4764c27b
......@@ -120,8 +120,8 @@ CREATE TABLE IF NOT EXISTS l2_transaction_withdrawals (
initiated_l2_event_guid VARCHAR NOT NULL UNIQUE REFERENCES l2_contract_events(guid) ON DELETE CASCADE,
-- Multistep (bedrock) process of a withdrawal
proven_l1_event_guid VARCHAR UNIQUE REFERENCES l1_contract_events(guid) ON DELETE CASCADE,
finalized_l1_event_guid VARCHAR UNIQUE REFERENCES l1_contract_events(guid) ON DELETE CASCADE,
proven_l1_event_guid VARCHAR UNIQUE REFERENCES l1_contract_events(guid) ON DELETE SET NULL ON UPDATE CASCADE,
finalized_l1_event_guid VARCHAR UNIQUE REFERENCES l1_contract_events(guid) ON DELETE SET NULL ON UPDATE CASCADE,
succeeded BOOLEAN,
-- transaction data
......@@ -145,7 +145,7 @@ CREATE TABLE IF NOT EXISTS l1_bridge_messages(
transaction_source_hash VARCHAR NOT NULL UNIQUE REFERENCES l1_transaction_deposits(source_hash) ON DELETE CASCADE,
sent_message_event_guid VARCHAR NOT NULL UNIQUE REFERENCES l1_contract_events(guid) ON DELETE CASCADE,
relayed_message_event_guid VARCHAR UNIQUE REFERENCES l2_contract_events(guid) ON DELETE CASCADE,
relayed_message_event_guid VARCHAR UNIQUE REFERENCES l2_contract_events(guid) ON DELETE SET NULL ON UPDATE CASCADE,
-- sent message
from_address VARCHAR NOT NULL,
......@@ -167,7 +167,7 @@ CREATE TABLE IF NOT EXISTS l2_bridge_messages(
transaction_withdrawal_hash VARCHAR NOT NULL UNIQUE REFERENCES l2_transaction_withdrawals(withdrawal_hash) ON DELETE CASCADE,
sent_message_event_guid VARCHAR NOT NULL UNIQUE REFERENCES l2_contract_events(guid) ON DELETE CASCADE,
relayed_message_event_guid VARCHAR UNIQUE REFERENCES l1_contract_events(guid) ON DELETE CASCADE,
relayed_message_event_guid VARCHAR UNIQUE REFERENCES l1_contract_events(guid) ON DELETE SET NULL ON UPDATE CASCADE,
-- sent message
from_address VARCHAR NOT NULL,
......
......@@ -182,7 +182,7 @@ func (b *BridgeProcessor) onL2Data(latestL2Header *types.Header) (errs error) {
}
// Finalized L2 Events (on L1)
if b.LastFinalizedL1Header == nil || b.LastFinalizedL1Header.Timestamp < latestL2Header.Time {
if b.LastL2Header != nil && (b.LastFinalizedL1Header == nil || b.LastFinalizedL1Header.Timestamp < latestL2Header.Time) {
if err := b.processFinalizedL1Events(latestL2Header); err != nil {
errs = errors.Join(errs, fmt.Errorf("failed processing finalized l1 events: %w", err))
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment