@@ -417,8 +417,13 @@ func (a *ethAPI) EthGetTransactionCount(ctx context.Context, sender types.EthAdd
417417 return types .EthUint64 (0 ), fmt .Errorf ("failed to process block param: %v, %w" , blkParam , err )
418418 }
419419
420+ stateCid , _ , err := a .em .chainModule .Stmgr .StateView (ctx , ts )
421+ if err != nil {
422+ return 0 , err
423+ }
424+
420425 // Get the actor state at the specified tipset
421- actor , err := a .em .chainModule .Stmgr .GetActorAt (ctx , addr , ts )
426+ actor , err := a .em .chainModule .Stmgr .GetActorRaw (ctx , addr , stateCid )
422427 if err != nil {
423428 if errors .Is (err , types .ErrActorNotFound ) {
424429 return 0 , nil
@@ -464,8 +469,10 @@ func (a *ethAPI) EthGetTransactionReceiptLimited(ctx context.Context, txHash typ
464469 return nil , fmt .Errorf ("failed to lookup Eth Txn %s as %s: %w" , txHash , c , err )
465470 }
466471 if msgLookup == nil {
467- // This is the best we can do. In theory, we could have just not indexed this
468- // transaction, but there's no way to check that here.
472+ // This is the best we can do. We may just not have indexed this transaction, or we may have a
473+ // limit applied and not searched far back enough, but we don't have a way to go. Because
474+ // Ethereum tooling expects an empty response for transaction-not-found, we don't have a way of
475+ // differentiating between "can't find" and "doesn't exist".
469476 return nil , nil
470477 }
471478
@@ -509,6 +516,14 @@ func (a *ethAPI) EthGetBlockReceiptsLimited(ctx context.Context, blockParam type
509516 return nil , fmt .Errorf ("failed to get tipset: %w" , err )
510517 }
511518
519+ head , err := a .chain .ChainHead (ctx )
520+ if err != nil {
521+ return nil , fmt .Errorf ("failed to get head: %v" , err )
522+ }
523+ if limit > constants .LookbackNoLimit && ts .Height () < head .Height () {
524+ return nil , fmt .Errorf ("tipset %s is older than the allowed lookback limit" , ts .Key ())
525+ }
526+
512527 tsCid , err := ts .Key ().Cid ()
513528 if err != nil {
514529 return nil , fmt .Errorf ("failed to get tipset key cid: %w" , err )
@@ -577,7 +592,12 @@ func (a *ethAPI) EthGetCode(ctx context.Context, ethAddr types.EthAddress, blkPa
577592 return nil , errors .New ("block param must not specify genesis block" )
578593 }
579594
580- actor , err := a .em .chainModule .Stmgr .GetActorAt (ctx , to , ts )
595+ stateCid , _ , err := a .em .chainModule .Stmgr .StateView (ctx , ts )
596+ if err != nil {
597+ return nil , err
598+ }
599+
600+ actor , err := a .em .chainModule .Stmgr .GetActorRaw (ctx , to , stateCid )
581601 if err != nil {
582602 if errors .Is (err , types .ErrActorNotFound ) {
583603 return nil , nil
@@ -605,7 +625,7 @@ func (a *ethAPI) EthGetCode(ctx context.Context, ethAddr types.EthAddress, blkPa
605625 // Try calling until we find a height with no migration.
606626 var res * types.InvocResult
607627 for {
608- res , err = a .em .chainModule .Stmgr .Call (ctx , msg , ts )
628+ res , err = a .em .chainModule .Stmgr .CallOnState (ctx , stateCid , msg , ts )
609629 if err != fork .ErrExpensiveFork {
610630 break
611631 }
@@ -664,13 +684,12 @@ func (a *ethAPI) EthGetStorageAt(ctx context.Context, ethAddr types.EthAddress,
664684 return nil , fmt .Errorf ("cannot get Filecoin address: %w" , err )
665685 }
666686
667- // use the system actor as the caller
668- from , err := address .NewIDAddress (0 )
687+ stateCid , _ , err := a .em .chainModule .Stmgr .StateView (ctx , ts )
669688 if err != nil {
670- return nil , fmt . Errorf ( "failed to construct system sender address: %w" , err )
689+ return nil , err
671690 }
672691
673- actor , err := a .em .chainModule .Stmgr .GetActorAt (ctx , to , ts )
692+ actor , err := a .em .chainModule .Stmgr .GetActorRaw (ctx , to , stateCid )
674693 if err != nil {
675694 if errors .Is (err , types .ErrActorNotFound ) {
676695 return types .EthBytes (make ([]byte , 32 )), nil
@@ -690,7 +709,7 @@ func (a *ethAPI) EthGetStorageAt(ctx context.Context, ethAddr types.EthAddress,
690709 }
691710
692711 msg := & types.Message {
693- From : from ,
712+ From : builtinactors . SystemActorAddr ,
694713 To : to ,
695714 Value : big .Zero (),
696715 Method : builtin .MethodsEVM .GetStorageAt ,
@@ -703,7 +722,7 @@ func (a *ethAPI) EthGetStorageAt(ctx context.Context, ethAddr types.EthAddress,
703722 // Try calling until we find a height with no migration.
704723 var res * types.InvocResult
705724 for {
706- res , err = a .em .chainModule .Stmgr .Call (ctx , msg , ts )
725+ res , err = a .em .chainModule .Stmgr .CallOnState (ctx , stateCid , msg , ts )
707726 if err != fork .ErrExpensiveFork {
708727 break
709728 }
0 commit comments