2022-08-29 14:25:30 +00:00
|
|
|
// stm: #integration
|
2021-05-18 20:32:10 +00:00
|
|
|
package itests
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2022-06-14 15:00:51 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
2022-05-17 22:33:15 +00:00
|
|
|
"github.com/filecoin-project/go-address"
|
|
|
|
"github.com/filecoin-project/go-bitfield"
|
2022-04-20 21:34:28 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/builtin"
|
|
|
|
minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner"
|
2021-05-18 20:32:10 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/crypto"
|
|
|
|
"github.com/filecoin-project/go-state-types/dline"
|
2022-06-14 15:00:51 +00:00
|
|
|
prooftypes "github.com/filecoin-project/go-state-types/proof"
|
|
|
|
|
2021-05-18 20:32:10 +00:00
|
|
|
"github.com/filecoin-project/lotus/api"
|
|
|
|
"github.com/filecoin-project/lotus/build"
|
|
|
|
"github.com/filecoin-project/lotus/chain/actors"
|
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
2021-06-18 18:45:29 +00:00
|
|
|
"github.com/filecoin-project/lotus/itests/kit"
|
2021-05-18 20:32:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestWindowPostDispute(t *testing.T) {
|
2021-12-13 12:41:04 +00:00
|
|
|
//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
|
2021-12-14 10:33:33 +00:00
|
|
|
|
|
|
|
//stm: @CHAIN_INCOMING_HANDLE_INCOMING_BLOCKS_001, @CHAIN_INCOMING_VALIDATE_BLOCK_PUBSUB_001, @CHAIN_INCOMING_VALIDATE_MESSAGE_PUBSUB_001
|
2021-06-23 15:37:43 +00:00
|
|
|
kit.Expensive(t)
|
2021-05-18 20:32:10 +00:00
|
|
|
|
2021-06-18 18:45:29 +00:00
|
|
|
kit.QuietMiningLogs()
|
2021-05-18 20:32:10 +00:00
|
|
|
|
|
|
|
blocktime := 2 * time.Millisecond
|
|
|
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
|
|
|
|
2021-06-17 12:22:13 +00:00
|
|
|
var (
|
2021-06-18 18:45:29 +00:00
|
|
|
client kit.TestFullNode
|
|
|
|
chainMiner kit.TestMiner
|
|
|
|
evilMiner kit.TestMiner
|
2021-06-17 12:22:13 +00:00
|
|
|
)
|
|
|
|
|
2021-05-18 20:32:10 +00:00
|
|
|
// First, we configure two miners. After sealing, we're going to turn off the first miner so
|
|
|
|
// it doesn't submit proofs.
|
|
|
|
//
|
|
|
|
// Then we're going to manually submit bad proofs.
|
2021-08-06 00:46:05 +00:00
|
|
|
opts := []kit.NodeOpt{kit.WithAllSubsystems()}
|
2021-06-18 18:45:29 +00:00
|
|
|
ens := kit.NewEnsemble(t, kit.MockProofs()).
|
2021-06-22 13:35:46 +00:00
|
|
|
FullNode(&client, opts...).
|
|
|
|
Miner(&chainMiner, &client, opts...).
|
|
|
|
Miner(&evilMiner, &client, append(opts, kit.PresealSectors(0))...).
|
2021-06-17 12:22:13 +00:00
|
|
|
Start()
|
2021-05-18 20:32:10 +00:00
|
|
|
|
|
|
|
defaultFrom, err := client.WalletDefaultAddress(ctx)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
// Mine with the _second_ node (the good one).
|
2021-06-22 16:07:14 +00:00
|
|
|
ens.InterconnectAll().BeginMining(blocktime, &chainMiner)
|
2021-05-18 20:32:10 +00:00
|
|
|
|
|
|
|
// Give the chain miner enough sectors to win every block.
|
2021-06-17 12:22:13 +00:00
|
|
|
chainMiner.PledgeSectors(ctx, 10, 0, nil)
|
2021-05-18 20:32:10 +00:00
|
|
|
// And the evil one 1 sector. No cookie for you.
|
2021-06-17 12:22:13 +00:00
|
|
|
evilMiner.PledgeSectors(ctx, 1, 0, nil)
|
2021-05-18 20:32:10 +00:00
|
|
|
|
|
|
|
// Let the evil miner's sectors gain power.
|
|
|
|
evilMinerAddr, err := evilMiner.ActorAddress(ctx)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2021-12-10 15:08:25 +00:00
|
|
|
//stm: @CHAIN_STATE_MINER_CALCULATE_DEADLINE_001
|
2021-05-18 20:32:10 +00:00
|
|
|
di, err := client.StateMinerProvingDeadline(ctx, evilMinerAddr, types.EmptyTSK)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2021-06-17 12:22:13 +00:00
|
|
|
t.Logf("Running one proving period\n")
|
2021-05-18 20:32:10 +00:00
|
|
|
|
2021-06-22 16:07:14 +00:00
|
|
|
waitUntil := di.PeriodStart + di.WPoStProvingPeriod*2 + 1
|
2021-06-17 12:22:13 +00:00
|
|
|
t.Logf("End for head.Height > %d", waitUntil)
|
2021-05-18 20:32:10 +00:00
|
|
|
|
2021-06-18 18:45:29 +00:00
|
|
|
ts := client.WaitTillChain(ctx, kit.HeightAtLeast(waitUntil))
|
2021-06-18 18:38:17 +00:00
|
|
|
t.Logf("Now head.Height = %d", ts.Height())
|
2021-05-18 20:32:10 +00:00
|
|
|
|
2021-12-10 15:08:25 +00:00
|
|
|
//stm: @CHAIN_STATE_MINER_POWER_001
|
2021-05-18 20:32:10 +00:00
|
|
|
p, err := client.StateMinerPower(ctx, evilMinerAddr, types.EmptyTSK)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
ssz, err := evilMiner.ActorSectorSize(ctx, evilMinerAddr)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
// make sure it has gained power.
|
|
|
|
require.Equal(t, p.MinerPower.RawBytePower, types.NewInt(uint64(ssz)))
|
|
|
|
|
2021-12-15 14:30:42 +00:00
|
|
|
//stm: @MINER_SECTOR_LIST_001
|
2022-08-02 13:29:38 +00:00
|
|
|
evilSectors, err := evilMiner.SectorsListNonGenesis(ctx)
|
2021-05-18 20:32:10 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
evilSectorNo := evilSectors[0] // only one.
|
2021-12-10 15:08:25 +00:00
|
|
|
//stm: @CHAIN_STATE_SECTOR_PARTITION_001
|
2021-05-18 20:32:10 +00:00
|
|
|
evilSectorLoc, err := client.StateSectorPartition(ctx, evilMinerAddr, evilSectorNo, types.EmptyTSK)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2021-06-17 12:22:13 +00:00
|
|
|
t.Log("evil miner stopping")
|
2021-05-18 20:32:10 +00:00
|
|
|
|
|
|
|
// Now stop the evil miner, and start manually submitting bad proofs.
|
|
|
|
require.NoError(t, evilMiner.Stop(ctx))
|
|
|
|
|
2021-06-17 12:22:13 +00:00
|
|
|
t.Log("evil miner stopped")
|
2021-05-18 20:32:10 +00:00
|
|
|
|
|
|
|
// Wait until we need to prove our sector.
|
|
|
|
for {
|
2021-12-10 15:08:25 +00:00
|
|
|
//stm: @CHAIN_STATE_MINER_CALCULATE_DEADLINE_001
|
2021-05-18 20:32:10 +00:00
|
|
|
di, err = client.StateMinerProvingDeadline(ctx, evilMinerAddr, types.EmptyTSK)
|
|
|
|
require.NoError(t, err)
|
2023-02-10 20:49:26 +00:00
|
|
|
if di.Index == evilSectorLoc.Deadline && di.CurrentEpoch-di.Open > 1 {
|
2021-05-18 20:32:10 +00:00
|
|
|
break
|
|
|
|
}
|
|
|
|
build.Clock.Sleep(blocktime)
|
|
|
|
}
|
|
|
|
|
2021-06-18 18:38:17 +00:00
|
|
|
err = submitBadProof(ctx, client, evilMiner.OwnerKey.Address, evilMinerAddr, di, evilSectorLoc.Deadline, evilSectorLoc.Partition)
|
2021-05-18 20:32:10 +00:00
|
|
|
require.NoError(t, err, "evil proof not accepted")
|
|
|
|
|
|
|
|
// Wait until after the proving period.
|
|
|
|
for {
|
2021-12-10 15:08:25 +00:00
|
|
|
//stm: @CHAIN_STATE_MINER_CALCULATE_DEADLINE_001
|
2021-05-18 20:32:10 +00:00
|
|
|
di, err = client.StateMinerProvingDeadline(ctx, evilMinerAddr, types.EmptyTSK)
|
|
|
|
require.NoError(t, err)
|
2021-06-09 23:00:06 +00:00
|
|
|
if di.Index != evilSectorLoc.Deadline {
|
2021-05-18 20:32:10 +00:00
|
|
|
break
|
|
|
|
}
|
|
|
|
build.Clock.Sleep(blocktime)
|
|
|
|
}
|
|
|
|
|
2021-06-17 12:22:13 +00:00
|
|
|
t.Log("accepted evil proof")
|
2021-05-18 20:32:10 +00:00
|
|
|
|
2021-12-10 15:08:25 +00:00
|
|
|
//stm: @CHAIN_STATE_MINER_POWER_001
|
2021-05-18 20:32:10 +00:00
|
|
|
// Make sure the evil node didn't lose any power.
|
|
|
|
p, err = client.StateMinerPower(ctx, evilMinerAddr, types.EmptyTSK)
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, p.MinerPower.RawBytePower, types.NewInt(uint64(ssz)))
|
|
|
|
|
|
|
|
// OBJECTION! The good miner files a DISPUTE!!!!
|
|
|
|
{
|
2022-04-20 21:34:28 +00:00
|
|
|
params := &minertypes.DisputeWindowedPoStParams{
|
2021-05-18 20:32:10 +00:00
|
|
|
Deadline: evilSectorLoc.Deadline,
|
|
|
|
PoStIndex: 0,
|
|
|
|
}
|
|
|
|
|
|
|
|
enc, aerr := actors.SerializeParams(params)
|
|
|
|
require.NoError(t, aerr)
|
|
|
|
|
|
|
|
msg := &types.Message{
|
|
|
|
To: evilMinerAddr,
|
2022-04-20 21:34:28 +00:00
|
|
|
Method: builtin.MethodsMiner.DisputeWindowedPoSt,
|
2021-05-18 20:32:10 +00:00
|
|
|
Params: enc,
|
|
|
|
Value: types.NewInt(0),
|
|
|
|
From: defaultFrom,
|
|
|
|
}
|
|
|
|
sm, err := client.MpoolPushMessage(ctx, msg, nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2021-06-17 12:22:13 +00:00
|
|
|
t.Log("waiting dispute")
|
2021-12-10 15:08:25 +00:00
|
|
|
//stm: @CHAIN_STATE_WAIT_MSG_001
|
2021-05-18 20:32:10 +00:00
|
|
|
rec, err := client.StateWaitMsg(ctx, sm.Cid(), build.MessageConfidence, api.LookbackNoLimit, true)
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Zero(t, rec.Receipt.ExitCode, "dispute not accepted: %s", rec.Receipt.ExitCode.Error())
|
|
|
|
}
|
|
|
|
|
2021-12-10 15:08:25 +00:00
|
|
|
//stm: @CHAIN_STATE_MINER_POWER_001
|
2021-05-18 20:32:10 +00:00
|
|
|
// Objection SUSTAINED!
|
|
|
|
// Make sure the evil node lost power.
|
|
|
|
p, err = client.StateMinerPower(ctx, evilMinerAddr, types.EmptyTSK)
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.True(t, p.MinerPower.RawBytePower.IsZero())
|
|
|
|
|
|
|
|
// Now we begin the redemption arc.
|
|
|
|
require.True(t, p.MinerPower.RawBytePower.IsZero())
|
|
|
|
|
|
|
|
// First, recover the sector.
|
|
|
|
|
|
|
|
{
|
2021-12-10 15:08:25 +00:00
|
|
|
//stm: @CHAIN_STATE_MINER_INFO_001
|
2021-05-18 20:32:10 +00:00
|
|
|
minerInfo, err := client.StateMinerInfo(ctx, evilMinerAddr, types.EmptyTSK)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-04-20 21:34:28 +00:00
|
|
|
params := &minertypes.DeclareFaultsRecoveredParams{
|
|
|
|
Recoveries: []minertypes.RecoveryDeclaration{{
|
2021-05-18 20:32:10 +00:00
|
|
|
Deadline: evilSectorLoc.Deadline,
|
|
|
|
Partition: evilSectorLoc.Partition,
|
|
|
|
Sectors: bitfield.NewFromSet([]uint64{uint64(evilSectorNo)}),
|
|
|
|
}},
|
|
|
|
}
|
|
|
|
|
|
|
|
enc, aerr := actors.SerializeParams(params)
|
|
|
|
require.NoError(t, aerr)
|
|
|
|
|
|
|
|
msg := &types.Message{
|
|
|
|
To: evilMinerAddr,
|
2022-04-20 21:34:28 +00:00
|
|
|
Method: builtin.MethodsMiner.DeclareFaultsRecovered,
|
2021-05-18 20:32:10 +00:00
|
|
|
Params: enc,
|
|
|
|
Value: types.FromFil(30), // repay debt.
|
|
|
|
From: minerInfo.Owner,
|
|
|
|
}
|
|
|
|
sm, err := client.MpoolPushMessage(ctx, msg, nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2021-12-10 15:08:25 +00:00
|
|
|
//stm: @CHAIN_STATE_WAIT_MSG_001
|
2021-05-18 20:32:10 +00:00
|
|
|
rec, err := client.StateWaitMsg(ctx, sm.Cid(), build.MessageConfidence, api.LookbackNoLimit, true)
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Zero(t, rec.Receipt.ExitCode, "recovery not accepted: %s", rec.Receipt.ExitCode.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
// Then wait for the deadline.
|
|
|
|
for {
|
2021-12-10 15:08:25 +00:00
|
|
|
//stm: @CHAIN_STATE_MINER_CALCULATE_DEADLINE_001
|
2021-05-18 20:32:10 +00:00
|
|
|
di, err = client.StateMinerProvingDeadline(ctx, evilMinerAddr, types.EmptyTSK)
|
|
|
|
require.NoError(t, err)
|
2023-02-10 20:49:26 +00:00
|
|
|
|
|
|
|
if di.Index == evilSectorLoc.Deadline && di.CurrentEpoch-di.Open > 1 {
|
2021-05-18 20:32:10 +00:00
|
|
|
break
|
|
|
|
}
|
|
|
|
build.Clock.Sleep(blocktime)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now try to be evil again
|
2021-06-18 18:38:17 +00:00
|
|
|
err = submitBadProof(ctx, client, evilMiner.OwnerKey.Address, evilMinerAddr, di, evilSectorLoc.Deadline, evilSectorLoc.Partition)
|
2021-05-18 20:32:10 +00:00
|
|
|
require.Error(t, err)
|
2022-05-17 22:33:15 +00:00
|
|
|
require.Contains(t, err.Error(), "invalid post was submitted")
|
|
|
|
require.Contains(t, err.Error(), "(RetCode=16)")
|
2021-05-18 20:32:10 +00:00
|
|
|
|
|
|
|
// It didn't work because we're recovering.
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestWindowPostDisputeFails(t *testing.T) {
|
2021-12-13 12:41:04 +00:00
|
|
|
//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
|
2021-12-10 15:08:25 +00:00
|
|
|
//stm: @CHAIN_STATE_MINER_GET_DEADLINES_001
|
2021-06-23 15:37:43 +00:00
|
|
|
kit.Expensive(t)
|
2021-05-18 20:32:10 +00:00
|
|
|
|
2021-06-18 18:45:29 +00:00
|
|
|
kit.QuietMiningLogs()
|
2021-05-18 20:32:10 +00:00
|
|
|
|
|
|
|
blocktime := 2 * time.Millisecond
|
|
|
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
|
|
|
|
2021-08-06 00:46:05 +00:00
|
|
|
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs())
|
2021-06-17 12:22:13 +00:00
|
|
|
ens.InterconnectAll().BeginMining(blocktime)
|
2021-05-18 20:32:10 +00:00
|
|
|
|
|
|
|
defaultFrom, err := client.WalletDefaultAddress(ctx)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
maddr, err := miner.ActorAddress(ctx)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
build.Clock.Sleep(time.Second)
|
|
|
|
|
2021-06-17 12:22:13 +00:00
|
|
|
miner.PledgeSectors(ctx, 10, 0, nil)
|
2021-05-18 20:32:10 +00:00
|
|
|
|
2021-12-10 15:08:25 +00:00
|
|
|
//stm: @CHAIN_STATE_MINER_CALCULATE_DEADLINE_001
|
2021-05-18 20:32:10 +00:00
|
|
|
di, err := client.StateMinerProvingDeadline(ctx, maddr, types.EmptyTSK)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2021-06-17 12:22:13 +00:00
|
|
|
t.Log("Running one proving period")
|
2021-06-22 16:07:14 +00:00
|
|
|
waitUntil := di.PeriodStart + di.WPoStProvingPeriod*2 + 1
|
2021-06-17 12:22:13 +00:00
|
|
|
t.Logf("End for head.Height > %d", waitUntil)
|
2021-05-18 20:32:10 +00:00
|
|
|
|
2021-06-18 18:45:29 +00:00
|
|
|
ts := client.WaitTillChain(ctx, kit.HeightAtLeast(waitUntil))
|
2021-06-18 18:38:17 +00:00
|
|
|
t.Logf("Now head.Height = %d", ts.Height())
|
2021-05-18 20:32:10 +00:00
|
|
|
|
|
|
|
ssz, err := miner.ActorSectorSize(ctx, maddr)
|
|
|
|
require.NoError(t, err)
|
2021-06-18 18:45:29 +00:00
|
|
|
expectedPower := types.NewInt(uint64(ssz) * (kit.DefaultPresealsPerBootstrapMiner + 10))
|
2021-05-18 20:32:10 +00:00
|
|
|
|
2021-12-10 15:08:25 +00:00
|
|
|
//stm: @CHAIN_STATE_MINER_POWER_001
|
2021-05-18 20:32:10 +00:00
|
|
|
p, err := client.StateMinerPower(ctx, maddr, types.EmptyTSK)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
// make sure it has gained power.
|
|
|
|
require.Equal(t, p.MinerPower.RawBytePower, expectedPower)
|
|
|
|
|
|
|
|
// Wait until a proof has been submitted.
|
|
|
|
var targetDeadline uint64
|
|
|
|
waitForProof:
|
|
|
|
for {
|
|
|
|
deadlines, err := client.StateMinerDeadlines(ctx, maddr, types.EmptyTSK)
|
|
|
|
require.NoError(t, err)
|
|
|
|
for dlIdx, dl := range deadlines {
|
|
|
|
nonEmpty, err := dl.PostSubmissions.IsEmpty()
|
|
|
|
require.NoError(t, err)
|
|
|
|
if nonEmpty {
|
|
|
|
targetDeadline = uint64(dlIdx)
|
|
|
|
break waitForProof
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
build.Clock.Sleep(blocktime)
|
|
|
|
}
|
|
|
|
|
|
|
|
for {
|
2021-12-10 15:08:25 +00:00
|
|
|
//stm: @CHAIN_STATE_MINER_CALCULATE_DEADLINE_001
|
2021-05-18 20:32:10 +00:00
|
|
|
di, err := client.StateMinerProvingDeadline(ctx, maddr, types.EmptyTSK)
|
|
|
|
require.NoError(t, err)
|
|
|
|
// wait until the deadline finishes.
|
|
|
|
if di.Index == ((targetDeadline + 1) % di.WPoStPeriodDeadlines) {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
build.Clock.Sleep(blocktime)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try to object to the proof. This should fail.
|
|
|
|
{
|
2022-04-20 21:34:28 +00:00
|
|
|
params := &minertypes.DisputeWindowedPoStParams{
|
2021-05-18 20:32:10 +00:00
|
|
|
Deadline: targetDeadline,
|
|
|
|
PoStIndex: 0,
|
|
|
|
}
|
|
|
|
|
|
|
|
enc, aerr := actors.SerializeParams(params)
|
|
|
|
require.NoError(t, aerr)
|
|
|
|
|
|
|
|
msg := &types.Message{
|
|
|
|
To: maddr,
|
2022-04-20 21:34:28 +00:00
|
|
|
Method: builtin.MethodsMiner.DisputeWindowedPoSt,
|
2021-05-18 20:32:10 +00:00
|
|
|
Params: enc,
|
|
|
|
Value: types.NewInt(0),
|
|
|
|
From: defaultFrom,
|
|
|
|
}
|
|
|
|
_, err := client.MpoolPushMessage(ctx, msg, nil)
|
|
|
|
require.Error(t, err)
|
2022-05-17 22:33:15 +00:00
|
|
|
require.Contains(t, err.Error(), "failed to dispute valid post")
|
|
|
|
require.Contains(t, err.Error(), "(RetCode=16)")
|
2021-05-18 20:32:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func submitBadProof(
|
|
|
|
ctx context.Context,
|
2021-06-18 18:38:17 +00:00
|
|
|
client api.FullNode, owner address.Address, maddr address.Address,
|
2021-05-18 20:32:10 +00:00
|
|
|
di *dline.Info, dlIdx, partIdx uint64,
|
|
|
|
) error {
|
|
|
|
head, err := client.ChainHead(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-12-10 15:08:25 +00:00
|
|
|
//stm: @CHAIN_STATE_MINER_INFO_001
|
2021-05-18 20:32:10 +00:00
|
|
|
minerInfo, err := client.StateMinerInfo(ctx, maddr, head.Key())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-12-10 15:08:25 +00:00
|
|
|
//stm: @CHAIN_STATE_GET_RANDOMNESS_FROM_TICKETS_001
|
2021-05-18 20:32:10 +00:00
|
|
|
commEpoch := di.Open
|
2021-09-12 02:24:53 +00:00
|
|
|
commRand, err := client.StateGetRandomnessFromTickets(
|
|
|
|
ctx, crypto.DomainSeparationTag_PoStChainCommit,
|
|
|
|
commEpoch, nil, head.Key(),
|
2021-05-18 20:32:10 +00:00
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-04-20 21:34:28 +00:00
|
|
|
params := &minertypes.SubmitWindowedPoStParams{
|
2021-05-18 20:32:10 +00:00
|
|
|
ChainCommitEpoch: commEpoch,
|
|
|
|
ChainCommitRand: commRand,
|
|
|
|
Deadline: dlIdx,
|
2022-04-20 21:34:28 +00:00
|
|
|
Partitions: []minertypes.PoStPartition{{Index: partIdx}},
|
|
|
|
Proofs: []prooftypes.PoStProof{{
|
2021-05-18 20:32:10 +00:00
|
|
|
PoStProof: minerInfo.WindowPoStProofType,
|
|
|
|
ProofBytes: []byte("I'm soooo very evil."),
|
|
|
|
}},
|
|
|
|
}
|
|
|
|
|
|
|
|
enc, aerr := actors.SerializeParams(params)
|
|
|
|
if aerr != nil {
|
|
|
|
return aerr
|
|
|
|
}
|
|
|
|
|
|
|
|
msg := &types.Message{
|
|
|
|
To: maddr,
|
2022-04-20 21:34:28 +00:00
|
|
|
Method: builtin.MethodsMiner.SubmitWindowedPoSt,
|
2021-05-18 20:32:10 +00:00
|
|
|
Params: enc,
|
|
|
|
Value: types.NewInt(0),
|
2021-06-21 20:25:55 +00:00
|
|
|
From: owner,
|
2021-05-18 20:32:10 +00:00
|
|
|
}
|
|
|
|
sm, err := client.MpoolPushMessage(ctx, msg, nil)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-12-10 15:08:25 +00:00
|
|
|
//stm: @CHAIN_STATE_WAIT_MSG_001
|
2021-05-18 20:32:10 +00:00
|
|
|
rec, err := client.StateWaitMsg(ctx, sm.Cid(), build.MessageConfidence, api.LookbackNoLimit, true)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if rec.Receipt.ExitCode.IsError() {
|
|
|
|
return rec.Receipt.ExitCode
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|