Skip to content

Fix: SystemExecution and ActorsCache #397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
fix: actors cache
  • Loading branch information
ziscky committed May 29, 2025
commit cd2392fe962f961085bc4d5efa8be01f8ae3fe39
50 changes: 37 additions & 13 deletions actors/cache/actors_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,32 @@ import (
"github.com/zondax/fil-parser/types"
)

// SystemActorsId Map to identify system actors which don't have an associated robust address
// SystemActorsId Map to identify system actors which don't have an associated robust address.
// https://github.com/filecoin-project/go-state-types/blob/571b84617a4b7fe032cf63c25e0c079f90e2f8a7/builtin/singletons.go#L9
var SystemActorsId = map[string]bool{
"f00": true,
"f01": true,
"f02": true,
"f03": true,
"f04": true,
"f05": true,
"f06": true,
"f07": true,
// system actor
"f00": true,
// init actor
"f01": true,
// reward actor
"f02": true,
// cron actor
"f03": true,
// storagepower actor
"f04": true,
// storagemarket actor
"f05": true,
// verifiedregistry actor
"f06": true,
// datacap actor
"f07": true,
// eam actor
"f010": true,
"f099": true,
}

// GenesisActorsId Map to identify actors created at genesis and don't have an associated robust address.
// Check data/genesis/{network}_genesis_balances.json
var GenesisActorsId = map[string]bool{
// multisig
"f080": true,
"f090": true,
Expand All @@ -50,10 +63,13 @@ var SystemActorsId = map[string]bool{
"f0119": true,
"f0120": true,
"f0122": true,
// burn address
"f099": true,
}

// CalibrationActorsId Map to identify system actors which don't have an associated robust address in the calibration network
// These are storage miners and multisig addresses that initiated the calibration network
// CalibrationActorsId Map to identify actors created at genesis which don't have an associated robust address in the calibration network.
// These are storage miners and multisig addresses that initiated the calibration network.
// Check data/genesis/calibration_genesis_balances.json
var CalibrationActorsId = map[string]bool{
// miners
"f01000": true,
Expand Down Expand Up @@ -145,10 +161,15 @@ func (a *ActorsCache) GetActorCode(add address.Address, key filTypes.TipSetKey,
}

func (a *ActorsCache) GetRobustAddress(add address.Address) (string, error) {
// check if the address is a system actor ( no robust address)
if _, ok := SystemActorsId[add.String()]; ok {
return add.String(), nil
}

// check if the address is a genesis actor ( no robust address)
if _, ok := GenesisActorsId[add.String()]; ok {
return add.String(), nil
}
// check if the address is a calibration genesis actor ( no robust address)
if tools.ParseRawNetworkName(a.networkName) == tools.CalibrationNetwork {
if _, ok := CalibrationActorsId[add.String()]; ok {
return add.String(), nil
Expand Down Expand Up @@ -263,9 +284,12 @@ func (a *ActorsCache) GetEVMSelectorSig(ctx context.Context, selectorID string)
return sig, nil
}

// IsSystemActor checks if addr is a system actor as defined here:
// https://github.com/filecoin-project/go-state-types/blob/571b84617a4b7fe032cf63c25e0c079f90e2f8a7/builtin/singletons.go#L9
func (a *ActorsCache) IsSystemActor(addr string) bool {
return SystemActorsId[addr]
}

func (a *ActorsCache) StoreEVMSelectorSig(ctx context.Context, selectorID string, sig string) error {
return a.offChainCache.StoreEVMSelectorSig(ctx, selectorID, sig)
}
Expand Down
2 changes: 1 addition & 1 deletion actors/cache/impl/onchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (m *OnChain) retrieveActorFromLotus(add address.Address, key filTypes.TipSe
}
actor, err = NodeApiCallWithRetry(nodeApiCallOptions, m.metrics)
if err != nil {
m.logger.Errorf("[ActorsCache] - retrieveActorFromLotus: %s", err.Error())
m.logger.Errorf("[ActorsCache] - retrieveActorFromLotus(%s): %s", add.String(), err.Error())
return cid.Cid{}, err
}
}
Expand Down
5 changes: 5 additions & 0 deletions actors/v2/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ func (i *Init) Exec(network string, height int64, msg *parser.LotusMessage, raw
addressInfo.ActorCid = createdActorCid.String()
addressInfo.ActorType = parseExecActor(createdActorName)
}
// Store the address info in the actors cache
// if an actor is created and it's Constructor is called in the next execution,
// we will not be able to get the actor type without this.
// NOT needed for Exec4(evm) as this is done in eam.Create
i.helper.GetActorsCache().StoreAddressInfo(*addressInfo)
}

return metadata, addressInfo, err
Expand Down