diff --git a/go/enclave/storage/enclavedb/events.go b/go/enclave/storage/enclavedb/events.go index 5d72f9cf13..5bd69656b9 100644 --- a/go/enclave/storage/enclavedb/events.go +++ b/go/enclave/storage/enclavedb/events.go @@ -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{}) } } diff --git a/go/enclave/storage/storage.go b/go/enclave/storage/storage.go index 85f919ea58..c2aa513060 100644 --- a/go/enclave/storage/storage.go +++ b/go/enclave/storage/storage.go @@ -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) }