Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
options: --tty
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
submodules: true
- uses: actions/setup-go@v6
Expand All @@ -34,7 +34,7 @@ jobs:
options: --tty
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
submodules: true
- uses: actions/setup-go@v6
Expand All @@ -54,7 +54,7 @@ jobs:
timeout-minutes: 120
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
submodules: true
- uses: actions/setup-go@v6
Expand Down
9 changes: 5 additions & 4 deletions actors/address.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package actors

import (
"context"
"fmt"

"github.com/filecoin-project/go-address"
Expand All @@ -13,7 +14,7 @@ import (
// if the address is a zero address account actor, it returns the robust address of the zero address account actor
// if the address is already a robust address, it returns the address
// if the address is f2 evm, we consolidate f2 -> f0 -> f4
func ConsolidateToRobustAddress(addr address.Address, h *helper.Helper, logger *logger.Logger, bestEffort bool, canonical bool) (string, error) {
func ConsolidateToRobustAddress(ctx context.Context, addr address.Address, h *helper.Helper, logger *logger.Logger, bestEffort bool, canonical bool) (string, error) {
actorCache := h.GetActorsCache()
if ok, _, _ := h.IsZeroAddressAccountActor(addr); ok {
return helper.ZeroAddressAccountActorRobust, nil
Expand All @@ -22,18 +23,18 @@ func ConsolidateToRobustAddress(addr address.Address, h *helper.Helper, logger *
if isRobust, _ := common.IsRobustAddress(addr); isRobust {
// we need to handle cases where a f2 address for evm actors is used
// f2 -> f0 -> f4, as we want to consolidate the address to f4 style
shortAddressStr, err := actorCache.GetShortAddress(addr, canonical)
shortAddressStr, err := actorCache.GetShortAddress(ctx, addr, canonical)
if err == nil {
shortAddress, _ := address.NewFromString(shortAddressStr)
addrStr, err := actorCache.GetRobustAddress(shortAddress, canonical)
addrStr, err := actorCache.GetRobustAddress(ctx, shortAddress, canonical)
if err == nil {
addr, _ = address.NewFromString(addrStr)
}
}
return addr.String(), nil
}

robustAddress, err := actorCache.GetRobustAddress(addr, canonical)
robustAddress, err := actorCache.GetRobustAddress(ctx, addr, canonical)
if err != nil && !bestEffort {
logger.Warnf("Error converting address %s to robust format: %v", addr, err)
return "", fmt.Errorf("error converting address to robust format: %v", err) // Fallback
Expand Down
48 changes: 24 additions & 24 deletions actors/cache/actors_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ func (a *ActorsCache) ClearBadAddressCache() {
a.badAddress.Clear()
}

func (a *ActorsCache) GetActorCode(add address.Address, key filTypes.TipSetKey, onChainOnly, canonical bool) (string, error) {
func (a *ActorsCache) GetActorCode(ctx context.Context, add address.Address, key filTypes.TipSetKey, onChainOnly, canonical bool) (string, error) {
addStr := add.String()

store, actorCode, err := a.getActorCode(add, key, onChainOnly, canonical)
store, actorCode, err := a.getActorCode(ctx, add, key, onChainOnly, canonical)
if err != nil {
a.logger.Errorf("[ActorsCache] - Unable to retrieve actor code from node: %s", err.Error())
if strings.Contains(err.Error(), "actor not found") {
Expand All @@ -144,7 +144,7 @@ func (a *ActorsCache) GetActorCode(add address.Address, key filTypes.TipSetKey,
}

// Code is not cached, store it
err = a.storeActorCode(add, types.AddressInfo{
err = a.storeActorCode(ctx, add, types.AddressInfo{
ActorCid: actorCode,
IsCanonical: canonical,
})
Expand All @@ -157,8 +157,8 @@ func (a *ActorsCache) GetActorCode(add address.Address, key filTypes.TipSetKey,
return actorCode, nil
}

func (a *ActorsCache) GetRobustAddress(add address.Address, canonical bool) (string, error) {
store, robust, err := a.getRobustAddress(add, canonical)
func (a *ActorsCache) GetRobustAddress(ctx context.Context, add address.Address, canonical bool) (string, error) {
store, robust, err := a.getRobustAddress(ctx, add, canonical)
if err != nil {
return "", err
}
Expand All @@ -168,7 +168,7 @@ func (a *ActorsCache) GetRobustAddress(add address.Address, canonical bool) (str
}

// Robust address is not cached, store it
err = a.storeRobustAddress(add, types.AddressInfo{
err = a.storeRobustAddress(ctx, add, types.AddressInfo{
Robust: robust,
IsCanonical: canonical,
})
Expand All @@ -181,8 +181,8 @@ func (a *ActorsCache) GetRobustAddress(add address.Address, canonical bool) (str
return robust, nil
}

func (a *ActorsCache) GetShortAddress(add address.Address, canonical bool) (string, error) {
store, short, err := a.getShortAddress(add, canonical)
func (a *ActorsCache) GetShortAddress(ctx context.Context, add address.Address, canonical bool) (string, error) {
store, short, err := a.getShortAddress(ctx, add, canonical)
if err != nil {
return "", err
}
Expand All @@ -191,7 +191,7 @@ func (a *ActorsCache) GetShortAddress(add address.Address, canonical bool) (stri
return short, nil
}
// Robust address is not cached, store it
err = a.storeShortAddress(add, types.AddressInfo{
err = a.storeShortAddress(ctx, add, types.AddressInfo{
Short: short,
IsCanonical: canonical,
})
Expand Down Expand Up @@ -242,10 +242,10 @@ func (a *ActorsCache) getEVMSelectorSig(ctx context.Context, selectorID string,
return "", err
}

func (a *ActorsCache) getShortAddress(add address.Address, canonical bool) (store bool, shortAddress string, err error) {
func (a *ActorsCache) getShortAddress(ctx context.Context, add address.Address, canonical bool) (store bool, shortAddress string, err error) {
addStr := add.String()
// Try canonical cache
short, err := a.offChainCache.GetShortAddress(add, canonical)
short, err := a.offChainCache.GetShortAddress(ctx, add, canonical)
if err == nil {
return false, short, nil
}
Expand All @@ -255,7 +255,7 @@ func (a *ActorsCache) getShortAddress(add address.Address, canonical bool) (stor
if a.isBadAddress(add) {
return false, "", fmt.Errorf("address %s is flagged as bad", addStr)
}
short, err = a.onChainCache.GetShortAddress(add, canonical)
short, err = a.onChainCache.GetShortAddress(ctx, add, canonical)
if err != nil {
a.logger.Debugf("[ActorsCache] - Unable to retrieve short address from onchain cache for address %s.", addStr)
return false, "", err
Expand All @@ -264,7 +264,7 @@ func (a *ActorsCache) getShortAddress(add address.Address, canonical bool) (stor
return true, short, nil
}

func (a *ActorsCache) getRobustAddress(add address.Address, canonical bool) (store bool, robustAddr string, err error) {
func (a *ActorsCache) getRobustAddress(ctx context.Context, add address.Address, canonical bool) (store bool, robustAddr string, err error) {
addStr := add.String()
// check if the address is a system actor ( no robust address)
if _, ok := SystemActorsId[addStr]; ok {
Expand All @@ -281,7 +281,7 @@ func (a *ActorsCache) getRobustAddress(add address.Address, canonical bool) (sto
}
}

robust, err := a.offChainCache.GetRobustAddress(add, canonical)
robust, err := a.offChainCache.GetRobustAddress(ctx, add, canonical)
if err == nil {
return false, robust, nil
}
Expand All @@ -290,7 +290,7 @@ func (a *ActorsCache) getRobustAddress(add address.Address, canonical bool) (sto
if a.isBadAddress(add) {
return false, "", fmt.Errorf("%w: address %s is flagged as bad", ErrBadAddress, addStr)
}
robust, err = a.onChainCache.GetRobustAddress(add, canonical)
robust, err = a.onChainCache.GetRobustAddress(ctx, add, canonical)
if err != nil {
a.logger.Debugf("[ActorsCache] - Unable to retrieve robust address from onchain cache for address %s.", addStr)
return false, "", err
Expand All @@ -299,9 +299,9 @@ func (a *ActorsCache) getRobustAddress(add address.Address, canonical bool) (sto
return true, robust, nil
}

func (a *ActorsCache) getActorCode(add address.Address, key filTypes.TipSetKey, onChainOnly, canonical bool) (store bool, actorCode string, err error) {
func (a *ActorsCache) getActorCode(ctx context.Context, add address.Address, key filTypes.TipSetKey, onChainOnly, canonical bool) (store bool, actorCode string, err error) {
addStr := add.String()
actorCode, err = a.offChainCache.GetActorCode(add, key, onChainOnly, canonical)
actorCode, err = a.offChainCache.GetActorCode(ctx, add, key, onChainOnly, canonical)
if err == nil {
return false, actorCode, nil
}
Expand All @@ -311,7 +311,7 @@ func (a *ActorsCache) getActorCode(add address.Address, key filTypes.TipSetKey,
return false, "", fmt.Errorf(" %w : %s is flagged as bad", ErrBadAddress, addStr)
}

actorCode, err = a.onChainCache.GetActorCode(add, key, onChainOnly, canonical)
actorCode, err = a.onChainCache.GetActorCode(ctx, add, key, onChainOnly, canonical)
if err != nil {
a.logger.Debugf("[ActorsCache] - Unable to retrieve actor code from onchain cache for address %s.", addStr)
return false, "", err
Expand All @@ -324,8 +324,8 @@ func (a *ActorsCache) StoreEVMSelectorSig(ctx context.Context, selectorID string
return a.offChainCache.StoreEVMSelectorSig(ctx, selectorID, sig, canonical)
}

func (a *ActorsCache) storeActorCode(add address.Address, info types.AddressInfo) error {
shortAddress, err := a.GetShortAddress(add, info.IsCanonical)
func (a *ActorsCache) storeActorCode(ctx context.Context, add address.Address, info types.AddressInfo) error {
shortAddress, err := a.GetShortAddress(ctx, add, info.IsCanonical)
if err != nil {
return err
}
Expand All @@ -339,8 +339,8 @@ func (a *ActorsCache) storeActorCode(add address.Address, info types.AddressInfo
return nil
}

func (a *ActorsCache) storeShortAddress(add address.Address, info types.AddressInfo) error {
_, robustAddress, err := a.getRobustAddress(add, info.IsCanonical)
func (a *ActorsCache) storeShortAddress(ctx context.Context, add address.Address, info types.AddressInfo) error {
_, robustAddress, err := a.getRobustAddress(ctx, add, info.IsCanonical)
if err != nil {
return err
}
Expand All @@ -354,8 +354,8 @@ func (a *ActorsCache) storeShortAddress(add address.Address, info types.AddressI
return nil
}

func (a *ActorsCache) storeRobustAddress(add address.Address, info types.AddressInfo) error {
_, shortAddress, err := a.getShortAddress(add, info.IsCanonical)
func (a *ActorsCache) storeRobustAddress(ctx context.Context, add address.Address, info types.AddressInfo) error {
_, shortAddress, err := a.getShortAddress(ctx, add, info.IsCanonical)
if err != nil {
return err
}
Expand Down
Loading
Loading