Skip to content

Commit

Permalink
- use the cached head block (#1678)
Browse files Browse the repository at this point in the history
- add canonical condition to sql to hit the index

(cherry picked from commit fb50c7b)
  • Loading branch information
tudor-malene committed Dec 8, 2023
1 parent 7a2bbaf commit 801d560
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions go/enclave/enclave.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func (e *enclaveImpl) Status() (common.Status, common.SystemError) {
return common.Status{StatusCode: common.Unavailable}, responses.ToInternalError(err)
}
var l1HeadHash gethcommon.Hash
l1Head, err := e.storage.FetchHeadBlock()
l1Head, err := e.l1BlockProcessor.GetHead()
if err != nil {
// this might be normal while enclave is starting up, just send empty hash
e.logger.Debug("failed to fetch L1 head block for status response", log.ErrKey, err)
Expand Down Expand Up @@ -1470,7 +1470,7 @@ func extractGetLogsParams(paramList []interface{}) (*filters.FilterCriteria, *ge

func (e *enclaveImpl) rejectBlockErr(cause error) *errutil.BlockRejectError {
var hash common.L1BlockHash
l1Head, err := e.storage.FetchHeadBlock()
l1Head, err := e.l1BlockProcessor.GetHead()
// todo - handle error
if err == nil {
hash = l1Head.Hash()
Expand Down
4 changes: 2 additions & 2 deletions go/enclave/storage/enclavedb/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ const (

isCanonQuery = "select is_canonical from block where hash=?"

queryTxList = "select tx.full_hash, batch.height from exec_tx join batch on batch.sequence=exec_tx.batch join tx on tx.hash=exec_tx.tx"
queryTxCountList = "select count(1) from exec_tx join batch on batch.sequence=exec_tx.batch"
queryTxList = "select tx.full_hash, batch.height from exec_tx join batch on batch.sequence=exec_tx.batch join tx on tx.hash=exec_tx.tx where batch.is_canonical=true"
queryTxCountList = "select count(1) from exec_tx join batch on batch.sequence=exec_tx.batch where batch.is_canonical=true"
)

// WriteBatchAndTransactions - persists the batch and the transactions
Expand Down

0 comments on commit 801d560

Please sign in to comment.