bd10bdf99a
* build: Bump version to v1.17.3-dev * build: set version to v1.18.0-dev * chore: actors: Allow builtin-actors to return a map of methods (#9342) * Allow builtin-actors to return a map of methods * go mod * Fix tests * Fix tests, check carefully please * Delete lotus-pond (#9352) * feat: add StateNetworkVersion to mpool API * chore: refactor: rename NewestNetworkVersion * feat: actors: Integrate datacap actor into lotus (#9348) * Integrate datacap actor * Implement datacap actor in chain/builtin * feat: support typed errors over RPC * chore: deps: update to go-jsonrpc 0.1.8 * remove duplicate import * fix: itest: check for closed connection * chore: refactor: move retry test to API * address magik supernit * Add ability to only have single partition per msg for partitions with recovery sectors * doc gen * Address comments * Return beneficiary info from miner state Info() * Update builtin-actors to dev/20220922-v9 which includes FIP-0045 changes in progress * Integrate verifreg changes to lotus * Setup datacap actor * Update builtin-actors to dev/20220922-v9-1 * Update datacap actor to query datacap instead of verifreg * update gst * update markets * update actors with hamt fix * update gst * Update datacap to parse tokens * Update bundles * datacap and verifreg actors use ID addresses without protocol byte * update builtin-actors to rc1 * update go-fil-markets * Update bundles to rc2 * Integrate the v9 migration * Add api for getting allocation * Add upgrade epoch for butterfly * Tweak PreSeal struct to be infra-friendly * docsgen * More tweaking of PreSeal for genesis * review fixes * Use fake cid for test * add butterfly artifacts for oct 5 upgrade * check datacaps for v8 verifreg match v9 datacap actor * Remove print statements * Update to go-state-types master * Update to go-state-types v0.9.0-rc1 * review fixes * use go-fil-markets v1.24.0-v17 * Add accessors for allocations and claims maps * fix: missing permissions tag * butterfly * update butterfly artifacts * sealing pipeline: Prepare deal assigning logic for FIP-45 * sealing pipeline: Get allocationId with StateApi * use NoAllocationID instead of nil AllocationId * address review * Add datacap actor to registry.go * Add cli for listing allocations and removing expired allocations * Update to go-state-types master * deps: upgrade go-merkledag to 0.8.0 * shark params * Update cli/filplus.go Co-authored-by: Aayush Rajasekaran <arajasek94@gmail.com> * revert change to verifreg util * docsgen-cli * miss the stuff * Update FFI * Update go-state-types to v0.9.0 * Update builtin-actors to v9.0.0 * add calib upgrade epcoh * update the upgrade envvar * kill shark * Remove fvm splash banner from nv17 upgrade * check invariance for pending deals and allocations * check pending verified deal proposal migrated to allocation * Add check for unsealed CID in precommit sectors * Fix counting of allocations in nv17 migration test * make gen * pass state trees as pointers * Add assertion that migrations with & without cache are the same * compare allocation to verified deal proposal * Fix miner state precommit info * fix migration test tool * add changelog * Update to go-state-types v0.9.1 * Integrate builtin-actors v9.0.1 * chore: ver: bump version for rc3 (#9512) * Bump version to 1.18.0-rc3 * Update CHANGELOG.md * Update CHANGELOG.md Co-authored-by: Aayush Rajasekaran <arajasek94@gmail.com> * Update CHANGELOG.md Co-authored-by: Aayush Rajasekaran <arajasek94@gmail.com> Co-authored-by: Jiaying Wang <42981373+jennijuju@users.noreply.github.com> Co-authored-by: Aayush Rajasekaran <arajasek94@gmail.com> * Migration: Use autobatch bs * Fix autobatch Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai> * Invoker: Use MethodMeta from go-state-types * Add a second premigration for nv17 * Add more shed tools for migration checking * address review * Lotus release v1.18.0-rc4 * fix: ci: fix app-image build on ci (#9527) * Remove old go version first * Add GO_VERSION file * Use GO_VERSION to set / verify go version * mv GO_VERSION GO_VERSION_MIN * Use GO_VERSION_MIN in Makefile check Co-authored-by: Ian Davis <jungziege@gmail.com> * Update to latest go-state-types for migration fixes * go mod tidy * fix: use api.ErrActorNotFound instead of types.ErrActorNotFound * fix: add fields to ForkUpgradeParams * docs: update actors_version_checklist.md * chore: fix lint * update to go state type v0.9.6 with market migration fix (#9545) * update go-state-types to v-0.9.7 * Add invariant checks to migration * fix invariant check: number of entries in datacap actor should include verifreg * Invariant checks: Only include not-activated deals * test: nv17 migration * Address review * add lotus-shed invariance method * Migration cli takes a stateroot cid and a height * make gen * Update to builtin-actors v9.0.2 * Failing test that shows that notaries can remove datacap from the verifreg actor * Test that should pass when the problem is solved * make gen * Review fixes * statemanager call function will return call information even if call errors * update go-state-types * update builtin-actors * bubble up errors properly from ApplyImplicitMessage * bump to rc5 * set new upgrade heights for calibnet * set new upgrade height for butterfly * tweak calibnet upgrade schedule * clarify changelog note about calibnet * butterfly * update calibnet artifacts * Allow setting local bundles for Debug FVM for av 9+ * fix: autobatch: remove potential deadlock when a block is missing Check the _underlying_ blockstore instead of recursing. Also, drop the lock before we do that. * fix imports * build: set shark mainnet epoch (#9640) * chore: build: Lotus release v1.18.0 (#9641) * Lotus release v1.18.0 * add changelog * address review * changelog improvement Co-authored-by: Jennifer Wang <jiayingw703@gmail.com> Co-authored-by: Jiaying Wang <42981373+jennijuju@users.noreply.github.com> Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai> Co-authored-by: Łukasz Magiera <magik6k@gmail.com> Co-authored-by: Łukasz Magiera <magik6k@users.noreply.github.com> Co-authored-by: Aayush <arajasek94@gmail.com> Co-authored-by: Geoff Stuart <geoff.vball@gmail.com> Co-authored-by: Shrenuj Bansal <shrenuj.bansal@protocol.ai> Co-authored-by: simlecode <69969590+simlecode@users.noreply.github.com> Co-authored-by: Rod Vagg <rod@vagg.org> Co-authored-by: Jakub Sztandera <kubuxu@protocol.ai> Co-authored-by: Ian Davis <jungziege@gmail.com> Co-authored-by: zenground0 <ZenGround0@users.noreply.github.com> Co-authored-by: Steven Allen <steven@stebalien.com>
312 lines
8.0 KiB
Go
312 lines
8.0 KiB
Go
// stm: #integration
|
|
package itests
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
logging "github.com/ipfs/go-log/v2"
|
|
"github.com/libp2p/go-libp2p/core/peer"
|
|
"github.com/stretchr/testify/require"
|
|
"golang.org/x/xerrors"
|
|
|
|
"github.com/filecoin-project/go-address"
|
|
"github.com/filecoin-project/go-state-types/big"
|
|
"github.com/filecoin-project/go-state-types/exitcode"
|
|
|
|
lapi "github.com/filecoin-project/lotus/api"
|
|
"github.com/filecoin-project/lotus/build"
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
"github.com/filecoin-project/lotus/itests/kit"
|
|
)
|
|
|
|
func TestAPI(t *testing.T) {
|
|
//stm: @CHAIN_SYNCER_LOAD_GENESIS_001, @CHAIN_SYNCER_FETCH_TIPSET_001,
|
|
//stm: @CHAIN_SYNCER_START_001, @CHAIN_SYNCER_SYNC_001, @BLOCKCHAIN_BEACON_VALIDATE_BLOCK_VALUES_01
|
|
//stm: @CHAIN_SYNCER_COLLECT_CHAIN_001, @CHAIN_SYNCER_COLLECT_HEADERS_001, @CHAIN_SYNCER_VALIDATE_TIPSET_001
|
|
//stm: @CHAIN_SYNCER_NEW_PEER_HEAD_001, @CHAIN_SYNCER_VALIDATE_MESSAGE_META_001, @CHAIN_SYNCER_STOP_001
|
|
|
|
//stm: @CHAIN_STATE_MINER_INFO_001
|
|
t.Run("direct", func(t *testing.T) {
|
|
runAPITest(t)
|
|
})
|
|
t.Run("rpc", func(t *testing.T) {
|
|
runAPITest(t, kit.ThroughRPC())
|
|
})
|
|
}
|
|
|
|
type apiSuite struct {
|
|
opts []interface{}
|
|
}
|
|
|
|
// runAPITest is the entry point to API test suite
|
|
func runAPITest(t *testing.T, opts ...interface{}) {
|
|
ts := apiSuite{opts: opts}
|
|
|
|
t.Run("version", ts.testVersion)
|
|
t.Run("id", ts.testID)
|
|
t.Run("testConnectTwo", ts.testConnectTwo)
|
|
t.Run("testMining", ts.testMining)
|
|
t.Run("testMiningReal", ts.testMiningReal)
|
|
t.Run("testSlowNotify", ts.testSlowNotify)
|
|
t.Run("testSearchMsg", ts.testSearchMsg)
|
|
t.Run("testOutOfGasError", ts.testOutOfGasError)
|
|
t.Run("testLookupNotFoundError", ts.testLookupNotFoundError)
|
|
t.Run("testNonGenesisMiner", ts.testNonGenesisMiner)
|
|
}
|
|
|
|
func (ts *apiSuite) testVersion(t *testing.T) {
|
|
lapi.RunningNodeType = lapi.NodeFull
|
|
t.Cleanup(func() {
|
|
lapi.RunningNodeType = lapi.NodeUnknown
|
|
})
|
|
|
|
full, _, _ := kit.EnsembleMinimal(t, ts.opts...)
|
|
|
|
v, err := full.Version(context.Background())
|
|
require.NoError(t, err)
|
|
|
|
versions := strings.Split(v.Version, "+")
|
|
require.NotZero(t, len(versions), "empty version")
|
|
require.Equal(t, versions[0], build.BuildVersion)
|
|
}
|
|
|
|
func (ts *apiSuite) testID(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
full, _, _ := kit.EnsembleMinimal(t, ts.opts...)
|
|
|
|
id, err := full.ID(ctx)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
require.Regexp(t, "^12", id.Pretty())
|
|
}
|
|
|
|
func (ts *apiSuite) testConnectTwo(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
one, two, _, ens := kit.EnsembleTwoOne(t, ts.opts...)
|
|
|
|
p, err := one.NetPeers(ctx)
|
|
require.NoError(t, err)
|
|
require.Empty(t, p, "node one has peers")
|
|
|
|
p, err = two.NetPeers(ctx)
|
|
require.NoError(t, err)
|
|
require.Empty(t, p, "node two has peers")
|
|
|
|
ens.InterconnectAll()
|
|
|
|
peers, err := one.NetPeers(ctx)
|
|
require.NoError(t, err)
|
|
|
|
countPeerIDs := func(peers []peer.AddrInfo) int {
|
|
peerIDs := make(map[peer.ID]struct{})
|
|
for _, p := range peers {
|
|
peerIDs[p.ID] = struct{}{}
|
|
}
|
|
|
|
return len(peerIDs)
|
|
}
|
|
|
|
require.Equal(t, countPeerIDs(peers), 2, "node one doesn't have 2 peers")
|
|
|
|
peers, err = two.NetPeers(ctx)
|
|
require.NoError(t, err)
|
|
require.Equal(t, countPeerIDs(peers), 2, "node one doesn't have 2 peers")
|
|
}
|
|
|
|
func (ts *apiSuite) testSearchMsg(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
full, _, ens := kit.EnsembleMinimal(t, ts.opts...)
|
|
|
|
senderAddr, err := full.WalletDefaultAddress(ctx)
|
|
require.NoError(t, err)
|
|
|
|
msg := &types.Message{
|
|
From: senderAddr,
|
|
To: senderAddr,
|
|
Value: big.Zero(),
|
|
}
|
|
|
|
ens.BeginMining(100 * time.Millisecond)
|
|
|
|
sm, err := full.MpoolPushMessage(ctx, msg, nil)
|
|
require.NoError(t, err)
|
|
|
|
//stm: @CHAIN_STATE_WAIT_MSG_001
|
|
res, err := full.StateWaitMsg(ctx, sm.Cid(), 1, lapi.LookbackNoLimit, true)
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, exitcode.Ok, res.Receipt.ExitCode, "message not successful")
|
|
|
|
//stm: @CHAIN_STATE_SEARCH_MSG_001
|
|
searchRes, err := full.StateSearchMsg(ctx, types.EmptyTSK, sm.Cid(), lapi.LookbackNoLimit, true)
|
|
require.NoError(t, err)
|
|
require.NotNil(t, searchRes)
|
|
|
|
require.Equalf(t, res.TipSet, searchRes.TipSet, "search ts: %s, different from wait ts: %s", searchRes.TipSet, res.TipSet)
|
|
}
|
|
|
|
func (ts *apiSuite) testOutOfGasError(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
full, _, _ := kit.EnsembleMinimal(t, ts.opts...)
|
|
|
|
senderAddr, err := full.WalletDefaultAddress(ctx)
|
|
require.NoError(t, err)
|
|
|
|
// the gas estimator API executes the message with gasLimit = BlockGasLimit
|
|
// Lowering it to 2 will cause it to run out of gas, testing the failure case we want
|
|
originalLimit := build.BlockGasLimit
|
|
build.BlockGasLimit = 2
|
|
defer func() {
|
|
build.BlockGasLimit = originalLimit
|
|
}()
|
|
|
|
msg := &types.Message{
|
|
From: senderAddr,
|
|
To: senderAddr,
|
|
Value: big.Zero(),
|
|
}
|
|
|
|
_, err = full.GasEstimateMessageGas(ctx, msg, nil, types.EmptyTSK)
|
|
require.Error(t, err, "should have failed")
|
|
require.True(t, xerrors.Is(err, &lapi.ErrOutOfGas{}))
|
|
}
|
|
|
|
func (ts *apiSuite) testLookupNotFoundError(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
full, _, _ := kit.EnsembleMinimal(t, ts.opts...)
|
|
|
|
addr, err := full.WalletNew(ctx, types.KTSecp256k1)
|
|
require.NoError(t, err)
|
|
|
|
_, err = full.StateLookupID(ctx, addr, types.EmptyTSK)
|
|
require.Error(t, err)
|
|
require.True(t, xerrors.Is(err, &lapi.ErrActorNotFound{}))
|
|
}
|
|
|
|
func (ts *apiSuite) testMining(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
full, miner, _ := kit.EnsembleMinimal(t, ts.opts...)
|
|
|
|
newHeads, err := full.ChainNotify(ctx)
|
|
require.NoError(t, err)
|
|
initHead := (<-newHeads)[0]
|
|
baseHeight := initHead.Val.Height()
|
|
|
|
h1, err := full.ChainHead(ctx)
|
|
require.NoError(t, err)
|
|
require.Equal(t, int64(h1.Height()), int64(baseHeight))
|
|
|
|
bm := kit.NewBlockMiner(t, miner)
|
|
bm.MineUntilBlock(ctx, full, nil)
|
|
require.NoError(t, err)
|
|
|
|
<-newHeads
|
|
|
|
h2, err := full.ChainHead(ctx)
|
|
require.NoError(t, err)
|
|
require.Greater(t, int64(h2.Height()), int64(h1.Height()))
|
|
|
|
bm.MineUntilBlock(ctx, full, nil)
|
|
require.NoError(t, err)
|
|
|
|
<-newHeads
|
|
|
|
h3, err := full.ChainHead(ctx)
|
|
require.NoError(t, err)
|
|
require.Greater(t, int64(h3.Height()), int64(h2.Height()))
|
|
}
|
|
|
|
func (ts *apiSuite) testMiningReal(t *testing.T) {
|
|
build.InsecurePoStValidation = false
|
|
defer func() {
|
|
build.InsecurePoStValidation = true
|
|
}()
|
|
|
|
ts.testMining(t)
|
|
}
|
|
|
|
func (ts *apiSuite) testSlowNotify(t *testing.T) {
|
|
_ = logging.SetLogLevel("rpc", "ERROR")
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
defer cancel()
|
|
|
|
full, miner, _ := kit.EnsembleMinimal(t, ts.opts...)
|
|
|
|
// Subscribe a bunch of times to make sure we fill up any RPC buffers.
|
|
var newHeadsChans []<-chan []*lapi.HeadChange
|
|
for i := 0; i < 100; i++ {
|
|
newHeads, err := full.ChainNotify(ctx)
|
|
require.NoError(t, err)
|
|
newHeadsChans = append(newHeadsChans, newHeads)
|
|
}
|
|
|
|
initHead := (<-newHeadsChans[0])[0]
|
|
baseHeight := initHead.Val.Height()
|
|
|
|
bm := kit.NewBlockMiner(t, miner)
|
|
bm.MineBlocks(ctx, time.Microsecond)
|
|
|
|
full.WaitTillChain(ctx, kit.HeightAtLeast(baseHeight+100))
|
|
|
|
// Make sure they were all closed, draining any buffered events first.
|
|
for _, ch := range newHeadsChans {
|
|
var ok bool
|
|
for ok {
|
|
select {
|
|
case _, ok = <-ch:
|
|
default:
|
|
t.Fatal("expected new heads channel to be closed")
|
|
}
|
|
}
|
|
}
|
|
|
|
// Make sure we can resubscribe and everything still works.
|
|
newHeads, err := full.ChainNotify(ctx)
|
|
require.NoError(t, err)
|
|
for i := 0; i < 10; i++ {
|
|
_, ok := <-newHeads
|
|
require.True(t, ok, "notify channel closed")
|
|
}
|
|
}
|
|
|
|
func (ts *apiSuite) testNonGenesisMiner(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
full, genesisMiner, ens := kit.EnsembleMinimal(t, append(ts.opts, kit.MockProofs())...)
|
|
ens.InterconnectAll().BeginMining(4 * time.Millisecond)
|
|
|
|
time.Sleep(1 * time.Second)
|
|
|
|
gaa, err := genesisMiner.ActorAddress(ctx)
|
|
require.NoError(t, err)
|
|
|
|
_, err = full.StateMinerInfo(ctx, gaa, types.EmptyTSK)
|
|
require.NoError(t, err)
|
|
|
|
var newMiner kit.TestMiner
|
|
ens.Miner(&newMiner, full,
|
|
kit.OwnerAddr(full.DefaultKey),
|
|
kit.SectorSize(2<<10),
|
|
kit.WithAllSubsystems(),
|
|
).Start().InterconnectAll()
|
|
|
|
ta, err := newMiner.ActorAddress(ctx)
|
|
require.NoError(t, err)
|
|
|
|
tid, err := address.IDFromAddress(ta)
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, uint64(1001), tid)
|
|
}
|