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 actors/v1/eam.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (p *ActorParser) parseCreate(rawParams, rawReturn []byte, msgCid cid.Cid) (
Short: parser.FilPrefix + strconv.FormatUint(r.ActorID, 10),
Robust: r.RobustAddress.String(),
EthAddress: parser.EthPrefix + hex.EncodeToString(r.EthAddress[:]),
ActorType: "evm",
ActorType: manifest.EvmKey,
CreationTxCid: msgCid.String(),
}

Expand Down Expand Up @@ -141,7 +141,7 @@ func (p *ActorParser) parseCreate2(rawParams, rawReturn []byte, msgCid cid.Cid)
Short: parser.FilPrefix + strconv.FormatUint(r.ActorID, 10),
Robust: r.RobustAddress.String(),
EthAddress: parser.EthPrefix + hex.EncodeToString(r.EthAddress[:]),
ActorType: "evm",
ActorType: manifest.EvmKey,
CreationTxCid: msgCid.String(),
}

Expand Down Expand Up @@ -181,7 +181,7 @@ func (p *ActorParser) parseCreateExternal(rawParams, rawReturn []byte, msgCid ci
Short: parser.FilPrefix + strconv.FormatUint(r.ActorID, 10),
Robust: r.RobustAddress.String(),
EthAddress: parser.EthPrefix + hex.EncodeToString(r.EthAddress[:]),
ActorType: "evm",
ActorType: manifest.EvmKey,
CreationTxCid: msgCid.String(),
}

Expand Down
3 changes: 2 additions & 1 deletion actors/v1/power.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/builtin/v11/power"
"github.com/filecoin-project/go-state-types/manifest"
"github.com/filecoin-project/specs-actors/actors/runtime/proof"

"github.com/zondax/fil-parser/parser"
Expand Down Expand Up @@ -105,7 +106,7 @@ func (p *ActorParser) parseCreateMiner(msg *parser.LotusMessage, rawReturn []byt
createdActor := &types.AddressInfo{
Short: r.IDAddress.String(),
Robust: r.RobustAddress.String(),
ActorType: "miner",
ActorType: manifest.MinerKey,
CreationTxCid: msg.Cid.String(),
}
metadata[parser.ReturnKey] = createdActor
Expand Down
2 changes: 1 addition & 1 deletion actors/v2/eam/eam.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (e *Eam) newEamCreate(r typegen.CBORUnmarshaler, msgCid cid.Cid) (string, *
Short: parser.FilPrefix + strconv.FormatUint(actorID, 10),
Robust: robustAddressStr,
EthAddress: parser.EthPrefix + ethAddress,
ActorType: "evm",
ActorType: manifest.EvmKey,
CreationTxCid: msgCid.String(),
}, createReturn, nil

Expand Down
3 changes: 2 additions & 1 deletion actors/v2/power/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
powerv16 "github.com/filecoin-project/go-state-types/builtin/v16/power"
powerv8 "github.com/filecoin-project/go-state-types/builtin/v8/power"
powerv9 "github.com/filecoin-project/go-state-types/builtin/v9/power"
"github.com/filecoin-project/go-state-types/manifest"
legacyv7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/power"
"github.com/ipfs/go-cid"
"github.com/zondax/fil-parser/parser"
Expand All @@ -22,7 +23,7 @@ func getAddressInfo(r powerReturn, msg *parser.LotusMessage) *types.AddressInfo
return &types.AddressInfo{
Short: idAddress.String(),
Robust: robustAddress.String(),
ActorType: "miner",
ActorType: manifest.MinerKey,
CreationTxCid: cid.String(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion actors/v2/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func ActorMethods(ctx context.Context, actorName string, height int64, network s
metricsClient := &metrics.ActorsMetricsClient{MetricsClient: metrics2.NewNoopMetricsClient()}
mActorName := actorName
actorParser := &ActorParser{network, helper, logger, metricsClient}
if actorName == manifest.EthAccountKey || actorName == manifest.PlaceholderKey {
if strings.Contains(actorName, manifest.EthAccountKey) || strings.Contains(actorName, manifest.PlaceholderKey) {
mActorName = manifest.EvmKey
}

Expand Down
17 changes: 11 additions & 6 deletions factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func (p *FilecoinParser) ParseGenesis(genesis *types.GenesisBalances, genesisTip
continue
}

addressInfo, err := getAddressInfo(balance.Key, genesisTipset.Key(), p.Helper)
addressInfo, err := getGenesisAddressInfo(balance.Key, genesisTipset.Key(), p.Helper)
if err != nil {
p.logger.Errorf("genesis could not get address info: %s. err: %s", balance.Key, err)
} else {
Expand All @@ -323,6 +323,7 @@ func (p *FilecoinParser) ParseGenesis(genesis *types.GenesisBalances, genesisTip
Level: 0,
TxTimestamp: genesisTimestamp,
TxTo: balance.Key,
TxFrom: parser.TxFromGenesis,
Amount: amount.Int,
Status: "Ok",
TxType: txType,
Expand All @@ -338,11 +339,12 @@ func (p *FilecoinParser) ParseGenesisMultisig(ctx context.Context, genesis *type
var multisigInfos []*types.MultisigInfo

for _, actor := range genesis.Actors.All {
addressInfo, err := getAddressInfo(actor.Key, genesisTipset.Key(), p.Helper)
addressInfo, err := getGenesisAddressInfo(actor.Key, genesisTipset.Key(), p.Helper)
if err != nil {
p.logger.Errorf("multisig genesis could not get address info: %s. err: %s", actor.Key, err)
continue
}
// actorName already parsed in getAddressInfo
actorName := addressInfo.ActorType

// check if the address is a multisig address
Expand Down Expand Up @@ -380,7 +382,7 @@ func (p *FilecoinParser) ParseGenesisMultisig(ctx context.Context, genesis *type
return multisigInfos, nil
}

func getAddressInfo(addrStr string, tipsetKey types2.TipSetKey, helper *helper2.Helper) (*types.AddressInfo, error) {
func getGenesisAddressInfo(addrStr string, tipsetKey types2.TipSetKey, helper *helper2.Helper) (*types.AddressInfo, error) {
filAdd, err := address.NewFromString(addrStr)
if err != nil {
return nil, fmt.Errorf("could not parse address: %s. err: %s", addrStr, err)
Expand All @@ -404,9 +406,12 @@ func getAddressInfo(addrStr string, tipsetKey types2.TipSetKey, helper *helper2.
}

return &types.AddressInfo{
Short: shortAdd,
Robust: robustAdd,
ActorCid: actorCode,
Short: shortAdd,
Robust: robustAdd,
ActorCid: actorCode,
// genesis transactions do not have a creation_tx_cid ,
// we use the tipset_cid in this case to enable users to find the genesis tipset from this address info.
CreationTxCid: tipsetKey.String(),
ActorType: tools.ParseActorName(actorName),
IsSystemActor: helper.IsSystemActor(filAdd) || helper.IsGenesisActor(filAdd),
}, nil
Expand Down
7 changes: 5 additions & 2 deletions parser/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ func AppendToAddressesMap(addressMap *types.AddressInfoMap, info ...*types.Addre
for _, i := range info {
switch i.ActorType {
case manifest.EvmKey:
cond := i.Robust != "" && i.Short != "" && i.Robust != i.Short && i.ActorCid != ""
// we store the address and later update it if it didn't have a creation_tx_cid or actor_cid
cond := i.Robust != "" && i.Short != "" && i.Robust != i.Short
if cond {
prev, ok := addressMap.Get(i.Short)
if ok {
Expand All @@ -79,7 +80,9 @@ func AppendToAddressesMap(addressMap *types.AddressInfoMap, info ...*types.Addre
case manifest.MultisigKey, manifest.MinerKey:
// with multisig accounts we can skip checking for robust addresses because some
// addresses do not have a robust address (genesis addresses)
cond := i.Short != "" && i.CreationTxCid != "" && i.ActorCid != ""

// we store the address and later update it if it didn't have a creation_tx_cid
cond := i.Short != "" && i.Short != i.Robust && i.ActorCid != ""
if i.IsSystemActor {
cond = i.Short != "" && i.ActorCid != "" && i.ActorType != ""
}
Expand Down
1 change: 1 addition & 0 deletions parser/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const (

TxTypeGenesis = "Genesis"
GenesisHeight = 0
TxFromGenesis = "genesis"

// FirstExportedMethodNumber is the lowest FRC-42 method number.
// https://github.com/filecoin-project/builtin-actors/blob/8fdbdec5e3f46b60ba0132d90533783a44c5961f/runtime/src/builtin/shared.rs#L58
Expand Down
3 changes: 2 additions & 1 deletion parser/helper/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,9 @@ func (h *Helper) GetActorNameFromAddress(add address.Address, height int64, key
if err != nil {
return cid.Undef, actors.UnknownStr, err
}
actorName = tools.ParseActorName(actorName)

if actorName == manifest.PlaceholderKey && !onChainOnly {
if strings.Contains(actorName, manifest.PlaceholderKey) && !onChainOnly {
onChainOnly = true
} else {
return c, actorName, nil
Expand Down
1 change: 0 additions & 1 deletion parser/v1/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ func (p *Parser) parseTrace(ctx context.Context, trace typesV1.ExecutionTraceV1,
_ = p.metrics.UpdateMethodNameErrorMetric(actorName, fmt.Sprint(trace.Msg.Method))
p.logger.Errorf("Could not get method name in transaction '%s' : method: %d height: %d err: %s", trace.Msg.Cid().String(), trace.Msg.Method, tipset.Height(), err)
}

actor, metadata, addressInfo, mErr := p.actorParser.GetMetadata(ctx, actorName, txType, &parser.LotusMessage{
To: trace.Msg.To,
From: trace.Msg.From,
Expand Down
6 changes: 3 additions & 3 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func TestParser_ParseTransactions(t *testing.T) {
height: "1419335",
results: expectedResults{
totalTraces: 37,
totalAddress: 16,
totalAddress: 18,
totalTxCids: 5,
},
},
Expand All @@ -294,6 +294,7 @@ func TestParser_ParseTransactions(t *testing.T) {

var p *FilecoinParser
var err error

if tt.url == nodeUrl {
p, err = NewFilecoinParser(l, mainnetCacheDataSource, gLogger)
} else {
Expand Down Expand Up @@ -2024,7 +2025,7 @@ func TestParser_ActorVersionComparison(t *testing.T) {
height: "1419335",
results: expectedResults{
totalTraces: 37,
totalAddress: 16,
totalAddress: 18,
totalTxCids: 5,
},
},
Expand Down Expand Up @@ -2121,7 +2122,6 @@ func TestParser_ActorVersionComparison(t *testing.T) {
assert.Equal(t, 0, len(failedTxType), "Tx metadata mismatch for tx_type: %v", failedTxType)
})
}

}

func getStoredGenesisData(network string) (*types.GenesisBalances, *types.ExtendedTipSet, error) {
Expand Down
2 changes: 1 addition & 1 deletion tools/miner/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (eg *eventGenerator) GenerateMinerEvents(ctx context.Context, transactions

func (eg *eventGenerator) isMinerStateMessage(actorName, txType string) bool {
switch {
case strings.EqualFold(actorName, manifest.MinerKey):
case strings.Contains(actorName, manifest.MinerKey):
return !strings.EqualFold(txType, parser.MethodOnDeferredCronEvent)
case strings.EqualFold(txType, parser.MethodAwardBlockReward):
return true
Expand Down