Refactor LookupID* APIs in StateManager and StateTree

The naming of `LookupID` can cause confusion when resolving actor IDs vs
 ID addresses. To avoid this:

* Refactor `StateTree` `LookupID` to `LookupIDAddress`, because it
returns ID address.
* Refactor `StateManager` `LookupID` to
`LookupIDAddress` because it also returns ID address via a chain call to
`StateTree`.
* Introduce a new API `StateManager` dedicated to resolving address to
actor ID, called `LookupID` which returns `abi.ActorID`.

For context, see:
 * https://github.com/filecoin-project/lotus/pull/11723#discussion_r1534728607
This commit is contained in:
Masih H. Derkani
2024-04-24 15:25:48 +01:00
parent d23ea7665b
commit f907354300
12 changed files with 43 additions and 26 deletions
+1 -1
View File
@@ -392,7 +392,7 @@ func lookupEthAddress(addr address.Address, st *state.StateTree) (ethtypes.EthAd
}
// Otherwise, resolve the ID addr.
idAddr, err := st.LookupID(addr)
idAddr, err := st.LookupIDAddress(addr)
if err != nil {
return ethtypes.EthAddress{}, err
}
+1 -1
View File
@@ -486,7 +486,7 @@ func (m *StateModule) StateLookupID(ctx context.Context, addr address.Address, t
return address.Undef, xerrors.Errorf("loading tipset %s: %w", tsk, err)
}
ret, err := m.StateManager.LookupID(ctx, addr, ts)
ret, err := m.StateManager.LookupIDAddress(ctx, addr, ts)
if err != nil && xerrors.Is(err, types.ErrActorNotFound) {
return address.Undef, &api.ErrActorNotFound{}
}