diff --git a/.circleci/config.yml b/.circleci/config.yml index f863d68170c..bc7737860d3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -874,6 +874,11 @@ workflows: suite: itest-get_messages_in_ts target: "./itests/get_messages_in_ts_test.go" + - test: + name: test-itest-lookup_robust_address + suite: itest-lookup_robust_address + target: "./itests/lookup_robust_address_test.go" + - test: name: test-itest-mempool suite: itest-mempool diff --git a/chain/stmgr/stmgr.go b/chain/stmgr/stmgr.go index ffef76ea986..1e4dab33aa9 100644 --- a/chain/stmgr/stmgr.go +++ b/chain/stmgr/stmgr.go @@ -354,13 +354,10 @@ func (sm *StateManager) LookupRobustAddress(ctx context.Context, idAddr address. } return nil }) - if err != nil { - if robustAddr == address.Undef { - return address.Undef, xerrors.Errorf("finding address: %w", err) - } - return robustAddr, nil + if robustAddr == address.Undef { + return address.Undef, xerrors.Errorf("finding address: %w", err) } - return address.Undef, xerrors.Errorf("address not found") + return robustAddr, nil } func (sm *StateManager) ValidateChain(ctx context.Context, ts *types.TipSet) error { diff --git a/itests/lookup_robust_address_test.go b/itests/lookup_robust_address_test.go new file mode 100644 index 00000000000..d2d49af8b4f --- /dev/null +++ b/itests/lookup_robust_address_test.go @@ -0,0 +1,32 @@ +package itests + +import ( + "context" + "testing" + "time" + + "github.com/filecoin-project/go-state-types/network" + "github.com/filecoin-project/lotus/chain/types" + "github.com/filecoin-project/lotus/itests/kit" + "github.com/stretchr/testify/require" +) + +func TestStateLookupRobustAddress(t *testing.T) { + ctx := context.Background() + kit.QuietMiningLogs() + + client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.GenesisNetworkVersion(network.Version15)) + ens.InterconnectAll().BeginMining(10 * time.Millisecond) + + addr, err := miner.ActorAddress(ctx) + require.NoError(t, err) + + // Look up the robust address + robAddr, err := client.StateLookupRobustAddress(ctx, addr, types.EmptyTSK) + require.NoError(t, err) + + // Check the id address for the given robust address and make sure it matches + idAddr, err := client.StateLookupID(ctx, robAddr, types.EmptyTSK) + require.NoError(t, err) + require.Equal(t, addr, idAddr) +} diff --git a/itests/self_sent_txn_test.go b/itests/self_sent_txn_test.go index ac8ce711c24..8d608ba95ef 100644 --- a/itests/self_sent_txn_test.go +++ b/itests/self_sent_txn_test.go @@ -102,23 +102,3 @@ func TestSelfSentTxnV14(t *testing.T) { require.NoError(t, err) require.Equal(t, exitcode.Ok, mLookup.Receipt.ExitCode) } - -func TestStateLookupRobustAddress(t *testing.T) { - ctx := context.Background() - kit.QuietMiningLogs() - - client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.GenesisNetworkVersion(network.Version15)) - ens.InterconnectAll().BeginMining(10 * time.Millisecond) - - addr, err := miner.ActorAddress(ctx) - require.NoError(t, err) - - // Look up the robust address - robAddr, err := client.StateLookupRobustAddress(ctx, addr, types.EmptyTSK) - require.NoError(t, err) - - // Check the id address for the given robust address and make sure it matches - idAddr, err := client.StateLookupID(ctx, robAddr, types.EmptyTSK) - require.NoError(t, err) - require.Equal(t, addr, idAddr) -} diff --git a/node/impl/full/state.go b/node/impl/full/state.go index ae0ddd2311b..51cb0dfbc3b 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -454,12 +454,6 @@ func (a *StateAPI) StateLookupRobustAddress(ctx context.Context, addr address.Ad if err != nil { return address.Undef, xerrors.Errorf("loading tipset %s: %w", tsk, err) } - if ts.Height() > policy.ChainFinality { - ts, err = a.StateManager.ChainStore().GetTipsetByHeight(ctx, ts.Height()-policy.ChainFinality, ts, true) - if err != nil { - return address.Undef, xerrors.Errorf("failed to load lookback tipset: %w", err) - } - } return a.StateManager.LookupRobustAddress(ctx, addr, ts) }