diff --git a/chain/datasource/datasource.go b/chain/datasource/datasource.go index e13d9ae3..fb0445a5 100644 --- a/chain/datasource/datasource.go +++ b/chain/datasource/datasource.go @@ -196,6 +196,24 @@ func (t *DataSource) Store() adt.Store { return t.node.Store() } +func (t *DataSource) getState(ctx context.Context, ts *types.TipSet) (*state.StateTree, error) { + cid := ts.ParentState() + key, keyErr := asKey(KeyPrefix{"stateTree"}, cid) + if keyErr == nil { + value, found := t.actorCache.Get(key) + if found { + return value.(*state.StateTree), nil + } + } + + stateTree, err := state.LoadStateTree(t.Store(), cid) + if err != nil { + return nil, err + } + t.actorCache.Add(key, stateTree) + return stateTree, err +} + func (t *DataSource) Actor(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*types.Actor, error) { metrics.RecordInc(ctx, metrics.DataSourceActorCacheRead) ctx, span := otel.Tracer("").Start(ctx, "DataSource.Actor") @@ -230,8 +248,9 @@ func (t *DataSource) Actor(ctx context.Context, addr address.Address, tsk types. // it includes the actor's state and relevant metadata such as family and name. // If the actor is not found or an error occurs during retrieval, the function // returns an error. -func (t *DataSource) ActorInfo(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*tasks.ActorInfo, error) { +func (t *DataSource) ActorInfo(ctx context.Context, addr address.Address, ts *types.TipSet) (*tasks.ActorInfo, error) { metrics.RecordInc(ctx, metrics.DataSourceActorCacheRead) + tsk := ts.Key() ctx, span := otel.Tracer("").Start(ctx, "DataSource.ActorInfo") if span.IsRecording() { span.SetAttributes(attribute.String("tipset", tsk.String())) @@ -248,8 +267,11 @@ func (t *DataSource) ActorInfo(ctx context.Context, addr address.Address, tsk ty return value.(*tasks.ActorInfo), nil } } - - act, err := t.Actor(ctx, addr, tsk) + stateTree, err := t.getState(ctx, ts) + if err != nil { + return nil, err + } + act, err := stateTree.GetActor(addr) actorInfo := tasks.ActorInfo{} if err == nil { if act.Address == nil { diff --git a/tasks/api.go b/tasks/api.go index 61d2bdf7..e8c087b3 100644 --- a/tasks/api.go +++ b/tasks/api.go @@ -58,7 +58,7 @@ type DataSource interface { TipSet(ctx context.Context, tsk types.TipSetKey) (*types.TipSet, error) Actor(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*types.Actor, error) ActorState(ctx context.Context, addr address.Address, ts *types.TipSet) (*api.ActorState, error) - ActorInfo(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*ActorInfo, error) + ActorInfo(ctx context.Context, addr address.Address, ts *types.TipSet) (*ActorInfo, error) CirculatingSupply(ctx context.Context, ts *types.TipSet) (api.CirculatingSupply, error) MinerPower(ctx context.Context, addr address.Address, ts *types.TipSet) (*api.MinerPower, error) ActorStateChanges(ctx context.Context, ts, pts *types.TipSet) (ActorStateChangeDiff, error) diff --git a/tasks/fevm/transaction/tasks.go b/tasks/fevm/transaction/tasks.go index d7504175..b8d8c872 100644 --- a/tasks/fevm/transaction/tasks.go +++ b/tasks/fevm/transaction/tasks.go @@ -62,12 +62,13 @@ func (p *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, execut if message.Message == nil { continue } - fromActorInfo, err := p.node.ActorInfo(ctx, message.Message.From, current.Key()) - if err != nil { + + if !util.IsEVMMessage(ctx, p.node, message.Message, current.Key()) { continue } - if !util.IsEVMMessage(ctx, p.node, message.Message, current.Key()) { + fromActorInfo, err := p.node.ActorInfo(ctx, message.Message.From, current) + if err != nil { continue } @@ -124,7 +125,7 @@ func (p *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, execut txnObj.To = txn.To.String() // Get the Actor from ActorInfo - toActorInfo, err := p.node.ActorInfo(ctx, message.Message.To, current.Key()) + toActorInfo, err := p.node.ActorInfo(ctx, message.Message.To, current) if err == nil && toActorInfo.Actor != nil && toActorInfo.Actor.Address != nil { txnObj.ToActorName = toActorInfo.ActorName txnObj.ToFilecoinAddress = toActorInfo.Actor.Address.String()