diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index d1274f425a..0e58d544cc 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -46,4 +46,6 @@ jobs: echo IMAGE_ID=$IMAGE_ID echo VERSION=$VERSION docker tag $IMAGE_NAME $IMAGE_ID:$VERSION + docker tag $IMAGE_NAME $IMAGE_ID:latest docker push $IMAGE_ID:$VERSION + docker push $IMAGE_ID:latest diff --git a/core/blockarchiver/client.go b/core/blockarchiver/client.go index 97d9398b2e..4049f38170 100644 --- a/core/blockarchiver/client.go +++ b/core/blockarchiver/client.go @@ -13,6 +13,7 @@ import ( "time" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/log" bundlesdk "github.com/bnb-chain/greenfield-bundle-sdk/bundle" ) @@ -124,6 +125,7 @@ func (c *Client) GetBundleBlocksByBlockNum(ctx context.Context, blockNum uint64) // GetBundleBlocks returns the bundle blocks by object name func (c *Client) GetBundleBlocks(ctx context.Context, objectName string) ([]*Block, error) { + log.Info("GetBundleBlocks", "objectName", objectName) var urlStr string parts := strings.Split(c.spHost, "//") urlStr = parts[0] + "//" + c.bucketName + "." + parts[1] + "/" + objectName @@ -134,34 +136,37 @@ func (c *Client) GetBundleBlocks(ctx context.Context, objectName string) ([]*Blo } resp, err := c.hc.Do(req) if err != nil { + log.Error("failed to do request", "err", err.Error()) return nil, err } defer resp.Body.Close() body, err := io.ReadAll(resp.Body) if err != nil { + log.Error("failed to read data", "error", err.Error()) return nil, err } tempFile, err := os.CreateTemp("", "bundle") if err != nil { - fmt.Printf("Failed to create temporary file: %v\n", err) + log.Error("Failed to create temporary file: %v\n", err) return nil, err } defer os.Remove(tempFile.Name()) // Write the content to the temporary file _, err = tempFile.Write(body) if err != nil { - fmt.Printf("Failed to write downloaded bundle to file: %v\n", err) + log.Error("Failed to write downloaded bundle to file: %v\n", err) return nil, err } defer tempFile.Close() bundleObjects, err := bundlesdk.NewBundleFromFile(tempFile.Name()) if err != nil { - fmt.Printf("Failed to create bundle from file: %v\n", err) + log.Error("Failed to create bundle from file: %v\n", err) return nil, err } + var blocksInfo []*Block for _, objMeta := range bundleObjects.GetBundleObjectsMeta() { objFile, _, err := bundleObjects.GetObject(objMeta.Name) @@ -184,7 +189,7 @@ func (c *Client) GetBundleBlocks(ctx context.Context, objectName string) ([]*Blo } blocksInfo = append(blocksInfo, blockInfo) } - + log.Info("fetched bundle of blocks", "number", blocksInfo[0].Number) return blocksInfo, nil } diff --git a/core/blockarchiver/types.go b/core/blockarchiver/types.go index 6c22cd5fd1..6df08d7d57 100644 --- a/core/blockarchiver/types.go +++ b/core/blockarchiver/types.go @@ -4,10 +4,10 @@ import ( "math/big" "strconv" "strings" - "sync" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" + "github.com/sasha-s/go-deadlock" ) // JsonError represents an error in JSON format @@ -123,7 +123,7 @@ type RequestLock struct { // if the number is within any of the ranges, but we don't need to populate the lookup every time a new range is added. rangeMap map[uint64]*Range lookupMap map[uint64]*Range - mu sync.RWMutex + mu deadlock.RWMutex } // NewRequestLock creates a new RequestLock @@ -145,6 +145,7 @@ func (rl *RequestLock) IsWithinAnyRange(num uint64) bool { // AddRange adds a new range to the cache func (rl *RequestLock) AddRange(from, to uint64) { log.Info("adding range", "from", from, "to", to) + defer log.Info("added range", "from", from, "to", to) rl.mu.Lock() defer rl.mu.Unlock() newRange := &Range{ @@ -157,11 +158,13 @@ func (rl *RequestLock) AddRange(from, to uint64) { for i := from; i <= to; i++ { rl.lookupMap[i] = newRange } + } // RemoveRange removes a range from the cache func (rl *RequestLock) RemoveRange(from, to uint64) { log.Info("removing range", "from", from, "to", to) + defer log.Info("removed range", "from", from, "to", to) rl.mu.Lock() defer rl.mu.Unlock()