Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug missing indexing #34

Merged
merged 3 commits into from
Mar 14, 2024
Merged
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
18 changes: 11 additions & 7 deletions core/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"math/big"
"time"

"github.com/ethereum-optimism/optimism/indexer/config"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
Expand Down Expand Up @@ -242,33 +243,36 @@ func (b *Processor) FinalizeMessage(ctx context.Context, wi *WithdrawalInitiated
return nil
}

func (b *Processor) GetProvenTime(wi *WithdrawalInitiatedLog) (*big.Int, error) {
func (b *Processor) GetProvenTime(wi *WithdrawalInitiatedLog) (*time.Time, error) {
optimismPortal, err := bindings.NewOptimismPortalCaller(b.cfg.L1Contracts.OptimismPortalProxy, b.L1Client)
if err != nil {
return nil, err
}

receipt, err := b.L1Client.TransactionReceipt(context.Background(), common.HexToHash(wi.TransactionHash))
receipt, err := b.L2Client.TransactionReceipt(context.Background(), common.HexToHash(wi.TransactionHash))
if err != nil {
return nil, err
return nil, fmt.Errorf("TransactionReceipt err: %v, wi: %v", err, wi)
}

withdrawal, err := b.toWithdrawal(wi, receipt)
if err != nil {
return nil, err
return nil, fmt.Errorf("toWithdrawal err: %v, wi: %v", err, wi)
}

withdrawalHash, err := b.hashWithdrawal(withdrawal)
if err != nil {
return nil, err
return nil, fmt.Errorf("hashWithdrawal err: %v, wi: %v", err, wi)
}

provenWithdrawal, err := optimismPortal.ProvenWithdrawals(nil, common.HexToHash(withdrawalHash))
if err != nil {
return nil, err
return nil, fmt.Errorf("optimismPortal.ProvenWithdrawals err: %v, wi: %v", err, wi)
}

return provenWithdrawal.Timestamp, nil
unixTimestamp := provenWithdrawal.Timestamp.Int64()
t := time.Unix(unixTimestamp, 0)
b.log.Info("GetProvenTime", "time", t.String(), "unixTimestamp", unixTimestamp)
return &t, nil
}

func (b *Processor) hashWithdrawal(w *bindings.TypesWithdrawalTransaction) (string, error) {
Expand Down
Loading