From 49e3aa71b7c5dda97c4867cf2b41e10be6b7c433 Mon Sep 17 00:00:00 2001 From: Jian Xiao Date: Tue, 19 Mar 2024 23:52:14 +0000 Subject: [PATCH] fix --- core/eth/tx.go | 11 ++++++++--- core/tx.go | 5 ++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/core/eth/tx.go b/core/eth/tx.go index 038d51862..6b29d1a73 100644 --- a/core/eth/tx.go +++ b/core/eth/tx.go @@ -4,6 +4,7 @@ import ( "context" "crypto/ecdsa" "encoding/json" + "fmt" "math/big" "slices" @@ -580,8 +581,10 @@ func (t *Transactor) GetQuorumBitmapForOperatorsAtBlockNumber(ctx context.Contex // Get the bitmap indices for all the given operators. type BitmapIndexOrError struct { bitmapIndex int - index int - err error + // The index is referring to the position of operator in operatorIds slice, + // i.e. the bitmap here (if err is nil) is for operatorIds[index]. + index int + err error } indexChan := make(chan BitmapIndexOrError, len(operatorIds)) indexPool := workerpool.New(maxNumWorkerPoolThreads) @@ -604,6 +607,7 @@ func (t *Transactor) GetQuorumBitmapForOperatorsAtBlockNumber(ctx context.Contex } indexPool.StopWait() close(indexChan) + // quorumBitmapIndices[i] is the bitmap index for operatorIds[i]. quorumBitmapIndices := make([]int, len(operatorIds)) for result := range indexChan { if result.err != nil { @@ -629,7 +633,7 @@ func (t *Transactor) GetQuorumBitmapForOperatorsAtBlockNumber(ctx context.Contex op := operatorIds[i] pool.Submit(func() { if bitmapIndex == -1 { - resultChan <- BitmapOrError{bitmap: nil, index: i, err: errors.New("no bitmap found for operator")} + resultChan <- BitmapOrError{bitmap: nil, index: i, err: fmt.Errorf("no bitmap index found for operator: %s", op.Hex())} return } bm, err := t.Bindings.RegistryCoordinator.GetQuorumBitmapAtBlockNumberByIndex(&bind.CallOpts{ @@ -644,6 +648,7 @@ func (t *Transactor) GetQuorumBitmapForOperatorsAtBlockNumber(ctx context.Contex bitmaps := make([]*big.Int, len(quorumBitmapIndices)) for result := range resultChan { if result.err != nil { + // For operators not found bitmap, set the bitmap to empty. bitmaps[result.index] = big.NewInt(0) } else { bitmaps[result.index] = result.bitmap diff --git a/core/tx.go b/core/tx.go index 8e41cf0c4..4c80d8858 100644 --- a/core/tx.go +++ b/core/tx.go @@ -103,7 +103,10 @@ type Transactor interface { // GetQuorumBitmapForOperatorsAtBlockNumber returns the quorum bitmaps for the operators // at the given block number. - GetQuorumBitmapForOperatorsAtBlockNumber(ctx context.Context, operatorId []OperatorID, blockNumber uint32) ([]*big.Int, error) + // The result slice will be of same length as "operatorIds", with the i-th entry be the + // result for the operatorIds[i]. If an operator failed to find bitmap, the corresponding + // result entry will be an empty bitmap. + GetQuorumBitmapForOperatorsAtBlockNumber(ctx context.Context, operatorIds []OperatorID, blockNumber uint32) ([]*big.Int, error) // GetOperatorSetParams returns operator set params for the quorum. GetOperatorSetParams(ctx context.Context, quorumID QuorumID) (*OperatorSetParam, error)