From e6b3ba0178fbbbe8a7f02dea6c4180c356482863 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Mon, 20 Jul 2020 20:33:15 +0200 Subject: [PATCH] Slow down pledgeSectors test Signed-off-by: Jakub Sztandera --- .circleci/config.yml | 1 + api/test/ccupgrade.go | 2 +- api/test/window_post.go | 19 +++++++++++++++---- cmd/lotus-storage-miner/rewards.go | 21 +++++---------------- node/impl/full/gas.go | 6 +++++- 5 files changed, 27 insertions(+), 22 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d88bbc9be..229bf3182 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -156,6 +156,7 @@ jobs: - download-params - go/install-gotestsum: gobin: $HOME/.local/bin + version: 0.5.2 - run: name: go test environment: diff --git a/api/test/ccupgrade.go b/api/test/ccupgrade.go index f8e8b1162..9380ac7be 100644 --- a/api/test/ccupgrade.go +++ b/api/test/ccupgrade.go @@ -54,7 +54,7 @@ func TestCCUpgrade(t *testing.T, b APIBuilder, blocktime time.Duration) { CC := abi.SectorNumber(GenesisPreseals + 1) Upgraded := CC + 1 - pledgeSectors(t, ctx, miner, 1) + pledgeSectors(t, ctx, miner, 1, nil) sl, err := miner.SectorsList(ctx) if err != nil { diff --git a/api/test/window_post.go b/api/test/window_post.go index 874bcadcf..03cc9535d 100644 --- a/api/test/window_post.go +++ b/api/test/window_post.go @@ -3,6 +3,7 @@ package test import ( "context" "fmt" + "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" @@ -41,26 +42,36 @@ func TestPledgeSector(t *testing.T, b APIBuilder, blocktime time.Duration, nSect mine := true done := make(chan struct{}) + blockNotif := make(chan struct{}, 1) go func() { defer close(done) for mine { build.Clock.Sleep(blocktime) - if err := sn[0].MineOne(ctx, func(bool, error) {}); err != nil { + if err := sn[0].MineOne(ctx, func(bool, error) { + select { + case blockNotif <- struct{}{}: + default: + } + + }); err != nil { t.Error(err) } } }() - pledgeSectors(t, ctx, miner, nSectors) + pledgeSectors(t, ctx, miner, nSectors, blockNotif) mine = false <-done } -func pledgeSectors(t *testing.T, ctx context.Context, miner TestStorageNode, n int) { +func pledgeSectors(t *testing.T, ctx context.Context, miner TestStorageNode, n int, blockNotif <-chan struct{}) { for i := 0; i < n; i++ { err := miner.PledgeSector(ctx) require.NoError(t, err) + if i%3 == 0 && blockNotif != nil { + <-blockNotif + } } for { @@ -131,7 +142,7 @@ func TestWindowPost(t *testing.T, b APIBuilder, blocktime time.Duration, nSector } }() - pledgeSectors(t, ctx, miner, nSectors) + pledgeSectors(t, ctx, miner, nSectors, nil) maddr, err := miner.ActorAddress(ctx) require.NoError(t, err) diff --git a/cmd/lotus-storage-miner/rewards.go b/cmd/lotus-storage-miner/rewards.go index 4152880ae..38a797dcc 100644 --- a/cmd/lotus-storage-miner/rewards.go +++ b/cmd/lotus-storage-miner/rewards.go @@ -22,13 +22,6 @@ var rewardsCmd = &cli.Command{ var rewardsRedeemCmd = &cli.Command{ Name: "redeem", Usage: "Redeem block rewards", - Flags: []cli.Flag{ - &cli.Int64Flag{ - Name: "gas-limit", - Usage: "set gas limit", - Value: 100000, - }, - }, Action: func(cctx *cli.Context) error { nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx) if err != nil { @@ -66,16 +59,12 @@ var rewardsRedeemCmd = &cli.Command{ return err } - gasLimit := cctx.Int64("gas-limit") - smsg, err := api.MpoolPushMessage(ctx, &types.Message{ - To: maddr, - From: mi.Owner, - Value: types.NewInt(0), - GasPrice: types.NewInt(1), - GasLimit: gasLimit, - Method: builtin.MethodsMiner.WithdrawBalance, - Params: params, + To: maddr, + From: mi.Owner, + Value: types.NewInt(0), + Method: builtin.MethodsMiner.WithdrawBalance, + Params: params, }) if err != nil { return err diff --git a/node/impl/full/gas.go b/node/impl/full/gas.go index 73367ea4b..d6e2caf2d 100644 --- a/node/impl/full/gas.go +++ b/node/impl/full/gas.go @@ -40,6 +40,7 @@ func (a *GasAPI) GasEstimateGasLimit(ctx context.Context, msgIn *types.Message, msg := &(*msgIn) msg.GasLimit = build.BlockGasLimit + msg.GasPrice = types.NewInt(1) ts, err := a.Cs.GetTipSetFromKey(tsk) if err != nil { @@ -47,8 +48,11 @@ func (a *GasAPI) GasEstimateGasLimit(ctx context.Context, msgIn *types.Message, } res, err := a.Stmgr.CallWithGas(ctx, msg, ts) + if err != nil { + return -1, xerrors.Errorf("CallWithGas failed: %w", err) + } if res.MsgRct.ExitCode != exitcode.Ok { - return -1, xerrors.Errorf("could not apply message: exit %s, reason: %s", res.MsgRct.ExitCode, res.Error) + return -1, xerrors.Errorf("message execution failed: exit %s, reason: %s", res.MsgRct.ExitCode, res.Error) } return res.MsgRct.GasUsed, nil