Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tudor-malene committed Dec 27, 2024
1 parent d928e35 commit 9eef2d9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions go/enclave/rpc/GetTransaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func GetTransactionExecute(builder *CallBuilder[gethcommon.Hash, RpcTransaction]
}

if rec != nil {
rpc.logger.Info("Cache hit for tx", log.TxKey, txHash)
rpc.logger.Debug("Cache hit for tx", log.TxKey, txHash)
// authorise - only the signer can request the transaction
if rec.From.Hex() != requester.Hex() {
builder.Status = NotAuthorised
Expand All @@ -60,7 +60,7 @@ func GetTransactionExecute(builder *CallBuilder[gethcommon.Hash, RpcTransaction]
return nil
}

rpc.logger.Info("Cache miss for tx", log.TxKey, txHash)
rpc.logger.Debug("Cache miss for tx", log.TxKey, txHash)

// Unlike in the Geth impl, we do not try and retrieve unconfirmed transactions from the mempool.
tx, blockHash, blockNumber, index, err := rpc.storage.GetTransaction(builder.ctx, *builder.Param)
Expand Down
13 changes: 4 additions & 9 deletions go/enclave/rpc/GetTransactionReceipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ func GetTransactionReceiptExecute(builder *CallBuilder[gethcommon.Hash, map[stri
}

if result != nil {
rpc.logger.Info("Cache hit for receipt", log.TxKey, txHash)
rpc.logger.Debug("Cache hit for receipt", log.TxKey, txHash)
builder.ReturnValue = &result
return nil
}

rpc.logger.Info("Cache miss for receipt", log.TxKey, txHash.String())
rpc.logger.Debug("Cache miss for receipt", log.TxKey, txHash.String())
exists, err := rpc.storage.ExistsTransactionReceipt(builder.ctx, txHash)
if err != nil {
return fmt.Errorf("could not retrieve transaction receipt in eth_getTransactionReceipt request. Cause: %w", err)
Expand All @@ -79,7 +79,7 @@ func GetTransactionReceiptExecute(builder *CallBuilder[gethcommon.Hash, map[stri
// We retrieve the transaction receipt.
receipt, err := rpc.storage.GetFilteredInternalReceipt(builder.ctx, txHash, requester, false)
if err != nil {
rpc.logger.Trace("error getting tx receipt", log.TxKey, txHash, log.ErrKey, err)
rpc.logger.Trace("Error getting tx receipt", log.TxKey, txHash, log.ErrKey, err)
if errors.Is(err, errutil.ErrNotFound) {
builder.Status = NotAuthorised
return nil
Expand Down Expand Up @@ -127,13 +127,8 @@ func fetchFromCache(ctx context.Context, storage storage.Storage, cacheService *
}
}
}
r := marshalReceipt(rec.Receipt, logs, rec.From, rec.To)

// after the receipt was requested by a user remove it from the cache
//err = cacheService.DelReceipt(ctx, txHash)
//if err != nil {
// return nil, err
//}
r := marshalReceipt(rec.Receipt, logs, rec.From, rec.To)
return r, nil
}

Expand Down
5 changes: 3 additions & 2 deletions go/enclave/storage/cache_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func NewCacheService(logger gethlog.Logger, testMode bool) *CacheService {
nrEnclaves := 20

nrReceipts := 15_000 // ~100M
receiptsTimeout := 4 * time.Minute
if testMode {
nrReceipts = 2500
}
Expand All @@ -106,7 +107,7 @@ func NewCacheService(logger gethlog.Logger, testMode bool) *CacheService {
eventTypeCache: newLFUCache[[]byte, *enclavedb.EventType](logger, nrEventTypes),
eventTopicCache: newLFUCache[[]byte, *enclavedb.EventTopic](logger, nrEventTypes),

receiptCache: newFifoCache(nrReceipts, 180*time.Second),
receiptCache: newFifoCache(nrReceipts, receiptsTimeout),
attestedEnclavesCache: newLFUCache[[]byte, *AttestedEnclave](logger, nrEnclaves),

// cache the latest received batches to avoid a lookup when streaming it back to the host after processing
Expand Down Expand Up @@ -235,7 +236,7 @@ func (cs *CacheService) CacheReceipts(results core.TxExecResults) {
From: txExecResult.TxWithSender.Sender,
To: txExecResult.TxWithSender.Tx.To(),
}
cs.logger.Info("Cache receipt", "tx", txExecResult.TxWithSender.Tx.Hash().String())
cs.logger.Debug("Cache receipt", "tx", txExecResult.TxWithSender.Tx.Hash().String())
}
cs.receiptCache.SetAll(receipts)
}
Expand Down

0 comments on commit 9eef2d9

Please sign in to comment.