Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
geoff-vball committed Apr 14, 2022
1 parent 9b77fa2 commit 4beb4ba
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 32 deletions.
5 changes: 5 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 3 additions & 6 deletions chain/stmgr/stmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
32 changes: 32 additions & 0 deletions itests/lookup_robust_address_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
20 changes: 0 additions & 20 deletions itests/self_sent_txn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
6 changes: 0 additions & 6 deletions node/impl/full/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 4beb4ba

Please sign in to comment.