Merge remote-tracking branch 'origin/master' into next
This commit is contained in:
commit
c9a845d3aa
@ -91,16 +91,11 @@ func (ci *ChainIndex) fillCache(tsk types.TipSetKey) (*lbEntry, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if parent.Height() > rheight {
|
|
||||||
return nil, xerrors.Errorf("cache is inconsistent")
|
|
||||||
}
|
|
||||||
|
|
||||||
rheight -= ci.skipLength
|
rheight -= ci.skipLength
|
||||||
|
|
||||||
var skipTarget *types.TipSet
|
var skipTarget *types.TipSet
|
||||||
if parent.Height() < rheight {
|
if parent.Height() < rheight {
|
||||||
skipTarget = parent
|
skipTarget = parent
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
skipTarget, err = ci.walkBack(parent, rheight)
|
skipTarget, err = ci.walkBack(parent, rheight)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -119,8 +114,9 @@ func (ci *ChainIndex) fillCache(tsk types.TipSetKey) (*lbEntry, error) {
|
|||||||
return lbe, nil
|
return lbe, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// floors to nearest skipLength multiple
|
||||||
func (ci *ChainIndex) roundHeight(h abi.ChainEpoch) abi.ChainEpoch {
|
func (ci *ChainIndex) roundHeight(h abi.ChainEpoch) abi.ChainEpoch {
|
||||||
return abi.ChainEpoch(h/ci.skipLength) * ci.skipLength
|
return (h / ci.skipLength) * ci.skipLength
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ci *ChainIndex) roundDown(ts *types.TipSet) (*types.TipSet, error) {
|
func (ci *ChainIndex) roundDown(ts *types.TipSet) (*types.TipSet, error) {
|
||||||
@ -152,6 +148,8 @@ func (ci *ChainIndex) walkBack(from *types.TipSet, to abi.ChainEpoch) (*types.Ti
|
|||||||
}
|
}
|
||||||
|
|
||||||
if to > pts.Height() {
|
if to > pts.Height() {
|
||||||
|
// in case pts is lower than the epoch we're looking for (null blocks)
|
||||||
|
// return a tipset above that height
|
||||||
return ts, nil
|
return ts, nil
|
||||||
}
|
}
|
||||||
if to == pts.Height() {
|
if to == pts.Height() {
|
||||||
|
@ -44,7 +44,8 @@ func TestIndexSeeks(t *testing.T) {
|
|||||||
}
|
}
|
||||||
cs.SetGenesis(gen)
|
cs.SetGenesis(gen)
|
||||||
|
|
||||||
for i := 0; i < 100; i++ {
|
// Put 113 blocks from genesis
|
||||||
|
for i := 0; i < 113; i++ {
|
||||||
nextts := mock.TipSet(mock.MkBlock(cur, 1, 1))
|
nextts := mock.TipSet(mock.MkBlock(cur, 1, 1))
|
||||||
|
|
||||||
if err := cs.PutTipSet(ctx, nextts); err != nil {
|
if err := cs.PutTipSet(ctx, nextts); err != nil {
|
||||||
@ -53,6 +54,7 @@ func TestIndexSeeks(t *testing.T) {
|
|||||||
cur = nextts
|
cur = nextts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Put 50 null epochs + 1 block
|
||||||
skip := mock.MkBlock(cur, 1, 1)
|
skip := mock.MkBlock(cur, 1, 1)
|
||||||
skip.Height += 50
|
skip.Height += 50
|
||||||
|
|
||||||
@ -66,9 +68,9 @@ func TestIndexSeeks(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
assert.Equal(t, abi.ChainEpoch(151), ts.Height())
|
assert.Equal(t, abi.ChainEpoch(164), ts.Height())
|
||||||
|
|
||||||
for i := 0; i <= 100; i++ {
|
for i := 0; i <= 113; i++ {
|
||||||
ts3, err := cs.GetTipsetByHeight(ctx, abi.ChainEpoch(i), skipts, false)
|
ts3, err := cs.GetTipsetByHeight(ctx, abi.ChainEpoch(i), skipts, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
31
cli/chain.go
31
cli/chain.go
@ -841,6 +841,10 @@ var slashConsensusFault = &cli.Command{
|
|||||||
Name: "miner",
|
Name: "miner",
|
||||||
Usage: "Miner address",
|
Usage: "Miner address",
|
||||||
},
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "extra",
|
||||||
|
Usage: "Extra block cid",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Action: func(cctx *cli.Context) error {
|
Action: func(cctx *cli.Context) error {
|
||||||
api, closer, err := GetFullNodeAPI(cctx)
|
api, closer, err := GetFullNodeAPI(cctx)
|
||||||
@ -885,10 +889,31 @@ var slashConsensusFault = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
params, err := actors.SerializeParams(&miner.ReportConsensusFaultParams{
|
params := miner.ReportConsensusFaultParams{
|
||||||
BlockHeader1: bh1,
|
BlockHeader1: bh1,
|
||||||
BlockHeader2: bh2,
|
BlockHeader2: bh2,
|
||||||
})
|
}
|
||||||
|
|
||||||
|
if cctx.String("extra") != "" {
|
||||||
|
cExtra, err := cid.Parse(cctx.String("extra"))
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("parsing cid extra: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
bExtra, err := api.ChainGetBlock(ctx, cExtra)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("getting block extra: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
be, err := cborutil.Dump(bExtra)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
params.BlockHeaderExtra = be
|
||||||
|
}
|
||||||
|
|
||||||
|
enc, err := actors.SerializeParams(¶ms)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -909,7 +934,7 @@ var slashConsensusFault = &cli.Command{
|
|||||||
GasPrice: types.NewInt(1),
|
GasPrice: types.NewInt(1),
|
||||||
GasLimit: 10000000,
|
GasLimit: 10000000,
|
||||||
Method: builtin.MethodsMiner.ReportConsensusFault,
|
Method: builtin.MethodsMiner.ReportConsensusFault,
|
||||||
Params: params,
|
Params: enc,
|
||||||
}
|
}
|
||||||
|
|
||||||
smsg, err := api.MpoolPushMessage(ctx, msg)
|
smsg, err := api.MpoolPushMessage(ctx, msg)
|
||||||
|
Loading…
Reference in New Issue
Block a user