Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tudor-malene committed Jun 14, 2024
1 parent 9b6df5f commit 183ca3f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 28 deletions.
2 changes: 0 additions & 2 deletions go/enclave/storage/enclavedb/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,6 @@ func loadLogs(ctx context.Context, db *sql.DB, requestingAccount *gethcommon.Add
for _, topic := range [][]byte{t0, t1, t2, t3} {
if len(topic) > 0 {
l.Topics = append(l.Topics, byteArrayToHash(topic))
} else {
l.Topics = append(l.Topics, gethcommon.Hash{})
}
}

Expand Down
52 changes: 26 additions & 26 deletions go/enclave/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,36 +590,36 @@ func (s *storageImpl) StoreBatch(ctx context.Context, batch *core.Batch, convert
return fmt.Errorf("could not write batch header. Cause: %w", err)
}

senders := make([]*uint64, len(batch.Transactions))
// insert the tx signers as externally owned accounts
for i, tx := range batch.Transactions {
sender, err := types.Sender(types.LatestSignerForChainID(tx.ChainId()), tx)
if err != nil {
return fmt.Errorf("could not read tx sender. Cause: %w", err)
}
id, err := s.readEOA(ctx, dbTx, sender)
if err != nil {
if errors.Is(err, errutil.ErrNotFound) {
wid, err := enclavedb.WriteEoa(ctx, dbTx, sender)
if err != nil {
return fmt.Errorf("could not write the eoa. Cause: %w", err)
// only insert transactions if this is the first time a batch of this height is created
if !existsHeight {
senders := make([]*uint64, len(batch.Transactions))
// insert the tx signers as externally owned accounts
for i, tx := range batch.Transactions {
sender, err := types.Sender(types.LatestSignerForChainID(tx.ChainId()), tx)
if err != nil {
return fmt.Errorf("could not read tx sender. Cause: %w", err)
}
id, err := s.readEOA(ctx, dbTx, sender)
if err != nil {
if errors.Is(err, errutil.ErrNotFound) {
wid, err := enclavedb.WriteEoa(ctx, dbTx, sender)
if err != nil {
return fmt.Errorf("could not write the eoa. Cause: %w", err)
}
id = &wid
//todo - decide how to handle the corner case where events were emitted before
//etId, _, err := s.findEventTopic(ctx, dbTx, sender.Bytes())
//if err == nil {
// err = enclavedb.UpdateEventTopic(ctx, dbTx, etId, id)
// if err != nil {
// return fmt.Errorf("could not update the event topic. Cause: %w", err)
// }
//}
}
id = &wid
//todo - decide how to handle the corner case where events were emitted before
//etId, _, err := s.findEventTopic(ctx, dbTx, sender.Bytes())
//if err == nil {
// err = enclavedb.UpdateEventTopic(ctx, dbTx, etId, id)
// if err != nil {
// return fmt.Errorf("could not update the event topic. Cause: %w", err)
// }
//}
}
senders[i] = id
}
senders[i] = id
}

// only insert transactions if this is the first time a batch of this height is created
if !existsHeight {
if err := enclavedb.WriteTransactions(ctx, dbTx, batch, senders); err != nil {
return fmt.Errorf("could not write transactions. Cause: %w", err)
}
Expand Down

0 comments on commit 183ca3f

Please sign in to comment.