From 60545e67226094356897264ca3dab5d15bf8e2a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 7 Aug 2020 14:43:32 +0200 Subject: [PATCH 01/13] mempool: Allow 0 gasPerf chains --- chain/messagepool/selection.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/chain/messagepool/selection.go b/chain/messagepool/selection.go index 33af8882a..c648c45ae 100644 --- a/chain/messagepool/selection.go +++ b/chain/messagepool/selection.go @@ -74,7 +74,7 @@ func (mp *MessagePool) selectMessages(curTs, ts *types.TipSet) ([]*types.SignedM return chains[i].Before(chains[j]) }) - if len(chains) != 0 && chains[0].gasPerf <= 0 { + if len(chains) != 0 && chains[0].gasPerf < 0 { log.Warnw("all messages in mpool have non-positive gas performance", "bestGasPerf", chains[0].gasPerf) return nil, nil } @@ -87,14 +87,14 @@ func (mp *MessagePool) selectMessages(curTs, ts *types.TipSet) ([]*types.SignedM last := len(chains) for i, chain := range chains { // does it fit in the block? - if chain.gasLimit <= gasLimit && chain.gasPerf > 0 { + if chain.gasLimit <= gasLimit && chain.gasPerf >= 0 { gasLimit -= chain.gasLimit result = append(result, chain.msgs...) continue } // did we run out of performing chains? - if chain.gasPerf <= 0 { + if chain.gasPerf < 0 { break } @@ -131,14 +131,14 @@ tailLoop: continue } // does it fit in the bock? - if chain.gasLimit <= gasLimit && chain.gasPerf > 0 { + if chain.gasLimit <= gasLimit && chain.gasPerf >= 0 { gasLimit -= chain.gasLimit result = append(result, chain.msgs...) continue } - // if gasPerf <= 0 we have no more profitable chains - if chain.gasPerf <= 0 { + // if gasPerf < 0 we have no more profitable chains + if chain.gasPerf < 0 { break tailLoop } From d31d6e61d8f98973844d4a63a0241dabefecde0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 7 Aug 2020 14:43:55 +0200 Subject: [PATCH 02/13] miner: Don't wait for beacon entries --- miner/miner.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/miner/miner.go b/miner/miner.go index 92fc7e2bc..102b49b0c 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -181,12 +181,12 @@ func (m *Miner) mine(ctx context.Context) { continue } - // just wait for the beacon entry to become available before we select our final mining base + /*// just wait for the beacon entry to become available before we select our final mining base _, err = m.api.BeaconGetEntry(ctx, prebase.TipSet.Height()+prebase.NullRounds+1) if err != nil { log.Errorf("failed getting beacon entry: %s", err) continue - } + }*/ base = prebase } @@ -396,7 +396,7 @@ func (m *Miner) mineOne(ctx context.Context, base *MiningBase) (*types.BlockMsg, tCreateBlock := build.Clock.Now() dur := tCreateBlock.Sub(start) - log.Infow("mined new block", "cid", b.Cid(), "height", b.Header.Height, "took", dur) + log.Infow("mined new block", "cid", b.Cid(), "height", b.Header.Height, "miner", b.Header.Miner, "parents", len(b.Header.Parents), "took", dur) if dur > time.Second*time.Duration(build.BlockDelaySecs) { log.Warnw("CAUTION: block production took longer than the block delay. Your computer may not be fast enough to keep up", "tMinerBaseInfo ", tMBI.Sub(start), From b216785071c823a00d2e1ee729757307433a7fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 7 Aug 2020 14:46:46 +0200 Subject: [PATCH 03/13] sync: Revert #2858 --- chain/sync.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chain/sync.go b/chain/sync.go index 9c5b2f24b..3a15ab791 100644 --- a/chain/sync.go +++ b/chain/sync.go @@ -1300,7 +1300,7 @@ loop: } // base is the tipset in the candidate chain at the height equal to our known tipset height. - if base := blockSet[len(blockSet)-1]; !types.CidArrsSubset(base.Parents().Cids(), known.Cids()) { + if base := blockSet[len(blockSet)-1]; !types.CidArrsEqual(base.Parents().Cids(), known.Cids()) { if base.Parents() == known.Parents() { // common case: receiving a block thats potentially part of the same tipset as our best block return blockSet, nil From 1101d4b66a8ecb47eb32b0f664eec15614663735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 7 Aug 2020 15:03:55 +0200 Subject: [PATCH 04/13] Fix testground build --- build/params_testground.go | 4 ++++ node/impl/full/gas.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/build/params_testground.go b/build/params_testground.go index 982d71b68..0a4c010e0 100644 --- a/build/params_testground.go +++ b/build/params_testground.go @@ -22,6 +22,10 @@ var ( BlocksPerEpoch = uint64(builtin.ExpectedLeadersPerEpoch) BlockMessageLimit = 512 BlockGasLimit = int64(100_000_000_000) + BlockGasTarget = int64(BlockGasLimit / 2) + BaseFeeMaxChangeDenom = int64(8) // 12.5% + InitialBaseFee = int64(100e6) + MinimumBaseFee = int64(100) BlockDelaySecs = uint64(builtin.EpochDurationSeconds) PropagationDelaySecs = uint64(6) diff --git a/node/impl/full/gas.go b/node/impl/full/gas.go index b7f443c0a..bd6e8793c 100644 --- a/node/impl/full/gas.go +++ b/node/impl/full/gas.go @@ -125,7 +125,7 @@ func (a *GasAPI) GasEstimateGasLimit(ctx context.Context, msgIn *types.Message, msg := *msgIn msg.GasLimit = build.BlockGasLimit - msg.GasFeeCap = types.NewInt(build.MinimumBaseFee + 1) + msg.GasFeeCap = types.NewInt(uint64(build.MinimumBaseFee) + 1) msg.GasPremium = types.NewInt(1) currTs := a.Chain.GetHeaviestTipSet() From 051be614527ea756f9c130962ce5ff9be95f20b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 7 Aug 2020 15:04:10 +0200 Subject: [PATCH 05/13] gofmt --- build/params_testground.go | 16 ++++++++-------- chain/sub/incoming.go | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/build/params_testground.go b/build/params_testground.go index 0a4c010e0..ffd5ac9a4 100644 --- a/build/params_testground.go +++ b/build/params_testground.go @@ -19,15 +19,15 @@ var ( UnixfsChunkSize = uint64(1 << 20) UnixfsLinksPerLevel = 1024 - BlocksPerEpoch = uint64(builtin.ExpectedLeadersPerEpoch) - BlockMessageLimit = 512 - BlockGasLimit = int64(100_000_000_000) - BlockGasTarget = int64(BlockGasLimit / 2) + BlocksPerEpoch = uint64(builtin.ExpectedLeadersPerEpoch) + BlockMessageLimit = 512 + BlockGasLimit = int64(100_000_000_000) + BlockGasTarget = int64(BlockGasLimit / 2) BaseFeeMaxChangeDenom = int64(8) // 12.5% - InitialBaseFee = int64(100e6) - MinimumBaseFee = int64(100) - BlockDelaySecs = uint64(builtin.EpochDurationSeconds) - PropagationDelaySecs = uint64(6) + InitialBaseFee = int64(100e6) + MinimumBaseFee = int64(100) + BlockDelaySecs = uint64(builtin.EpochDurationSeconds) + PropagationDelaySecs = uint64(6) AllowableClockDriftSecs = uint64(1) diff --git a/chain/sub/incoming.go b/chain/sub/incoming.go index d0330be63..86f8eeec9 100644 --- a/chain/sub/incoming.go +++ b/chain/sub/incoming.go @@ -10,11 +10,11 @@ import ( "golang.org/x/xerrors" address "github.com/filecoin-project/go-address" - blocks "github.com/ipfs/go-block-format" - bserv "github.com/ipfs/go-blockservice" miner "github.com/filecoin-project/specs-actors/actors/builtin/miner" "github.com/filecoin-project/specs-actors/actors/util/adt" lru "github.com/hashicorp/golang-lru" + blocks "github.com/ipfs/go-block-format" + bserv "github.com/ipfs/go-blockservice" "github.com/ipfs/go-cid" cbor "github.com/ipfs/go-ipld-cbor" logging "github.com/ipfs/go-log/v2" From 73342e1fcf45bc8cbb3df78629ba615469a0e0d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 7 Aug 2020 15:19:12 +0200 Subject: [PATCH 06/13] pond: Fix network setup --- lotuspond/front/src/NodeList.js | 2 +- lotuspond/front/src/StorageNode.js | 2 +- lotuspond/spawn.go | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lotuspond/front/src/NodeList.js b/lotuspond/front/src/NodeList.js index 78203929b..a29d723c0 100644 --- a/lotuspond/front/src/NodeList.js +++ b/lotuspond/front/src/NodeList.js @@ -35,7 +35,7 @@ class NodeList extends React.Component { async mountNode(node) { const token = await this.props.client.call('Pond.TokenFor', [node.ID]) - const client = new Client(`ws://127.0.0.1:${node.ApiPort}/rpc/v0?token=${token}`) + const client = new Client(`ws://127.0.0.1:${node.APIPort}/rpc/v0?token=${token}`) client.on('open', async () => { const id = await client.call("Filecoin.ID", []) diff --git a/lotuspond/front/src/StorageNode.js b/lotuspond/front/src/StorageNode.js index 4f2005a67..bf85de642 100644 --- a/lotuspond/front/src/StorageNode.js +++ b/lotuspond/front/src/StorageNode.js @@ -59,7 +59,7 @@ class StorageNode extends React.Component { token: token, })) - const client = new Client(`ws://127.0.0.1:${this.props.node.ApiPort}/rpc/v0?token=${token}`) + const client = new Client(`ws://127.0.0.1:${this.props.node.APIPort}/rpc/v0?token=${token}`) client.on('open', async () => { this.setState(() => ({ state: stateConnected, diff --git a/lotuspond/spawn.go b/lotuspond/spawn.go index e28ac8753..f4e8decee 100644 --- a/lotuspond/spawn.go +++ b/lotuspond/spawn.go @@ -20,6 +20,7 @@ import ( "github.com/filecoin-project/specs-actors/actors/abi" "github.com/filecoin-project/specs-actors/actors/builtin/miner" + "github.com/filecoin-project/lotus/chain/gen" "github.com/filecoin-project/lotus/cmd/lotus-seed/seed" "github.com/filecoin-project/lotus/genesis" ) @@ -69,6 +70,7 @@ func (api *api) Spawn() (nodeInfo, error) { Balance: types.FromFil(5000000), Meta: (&genesis.AccountMeta{Owner: genm.Owner}).ActorMeta(), }) + template.VerifregRootKey = gen.DefaultVerifregRootkeyActor tb, err := json.Marshal(&template) if err != nil { From cad59b045be24f59a1ad952ae93327a4612701b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 7 Aug 2020 16:07:34 +0200 Subject: [PATCH 07/13] More pond-related fixes --- chain/vm/invoker.go | 2 +- lotuspond/front/src/Address.js | 14 +++++++------- lotuspond/front/src/Block.js | 2 ++ lotuspond/front/src/State.js | 8 ++++---- lotuspond/front/src/StorageNode.js | 5 ++--- lotuspond/front/src/chain/send.js | 6 ------ node/impl/full/state.go | 8 ++++---- 7 files changed, 20 insertions(+), 25 deletions(-) diff --git a/chain/vm/invoker.go b/chain/vm/invoker.go index 8bbb27ecc..56f769da2 100644 --- a/chain/vm/invoker.go +++ b/chain/vm/invoker.go @@ -193,7 +193,7 @@ func DumpActorState(code cid.Cid, b []byte) (interface{}, error) { } if err := um.UnmarshalCBOR(bytes.NewReader(b)); err != nil { - return nil, err + return nil, xerrors.Errorf("unmarshaling actor state: %w", err) } return rv.Elem().Interface(), nil diff --git a/lotuspond/front/src/Address.js b/lotuspond/front/src/Address.js index 7ca2ea888..b2987646e 100644 --- a/lotuspond/front/src/Address.js +++ b/lotuspond/front/src/Address.js @@ -52,7 +52,7 @@ class Address extends React.Component { balance = await this.props.client.call('Filecoin.WalletBalance', [this.props.addr]) actor = await this.props.client.call('Filecoin.StateGetActor', [this.props.addr, (this.props.ts || {}).Cids]) - actorInfo = await this.actorInfo(actor) + actorInfo = await this.actorInfo(actor, this.props.addr) if(this.props.miner) { minerInfo = await this.props.client.call('Filecoin.StateMinerPower', [this.props.addr, (this.props.ts || {}).Cids]) } @@ -70,7 +70,7 @@ class Address extends React.Component { this.props.mountWindow((onClose) => ) } - async actorInfo(actor) { + async actorInfo(actor, addr) { const c = new CID(actor.Code['/']) const mh = multihash.decode(c.multihash) // TODO: check identity @@ -82,7 +82,7 @@ class Address extends React.Component { let info = ({mh.digest.toString()}{method}) switch(mh.digest.toString()) { case 'paych': - const actstate = await this.props.client.call('Filecoin.StateReadState', [actor, (this.props.ts || {}).Cids]) + const actstate = await this.props.client.call('Filecoin.StateReadState', [addr, (this.props.ts || {}).Cids]) info = ({mh.digest.toString()}{method} to
) } @@ -97,10 +97,10 @@ class Address extends React.Component { render() { let add20k = if(this.props.addN) { - add20k =   this.props.addN(this.props.addr, 200000)}>[+200k] + add20k =   this.props.addN(this.props.addr, 2e+18)}>[+2] if (this.props.add10k) { - add20k = {add20k}  this.props.addN(this.props.addr, 2000000)}>[+2M] - add20k = {add20k}  this.props.addN(this.props.addr, 20000000)}>[+20M] + add20k = {add20k}  this.props.addN(this.props.addr, 20e+18)}>[+20] + add20k = {add20k}  this.props.addN(this.props.addr, 200e+18)}>[+200] add20k = {add20k}  this.addColl()}>[+C] } } @@ -138,7 +138,7 @@ class Address extends React.Component { let minerInfo = if(this.state.minerInfo) { - minerInfo =  Power: {this.state.minerInfo.MinerPower} ({this.state.minerInfo.MinerPower/this.state.minerInfo.TotalPower*100}%) + minerInfo =  Power: {this.state.minerInfo.MinerPower.QualityAdjPower} ({this.state.minerInfo.MinerPower.QualityAdjPower/this.state.minerInfo.TotalPower.QualityAdjPower*100}%) } return {addr}{balance}{actInfo}{nonce}{add20k}{transfer}{minerInfo} diff --git a/lotuspond/front/src/Block.js b/lotuspond/front/src/Block.js index 44104d483..4bae57c81 100644 --- a/lotuspond/front/src/Block.js +++ b/lotuspond/front/src/Block.js @@ -70,6 +70,8 @@ class Block extends React.Component {  
 
 
+  
+  
 
----
diff --git a/lotuspond/front/src/State.js b/lotuspond/front/src/State.js index ade42f2e5..04175d231 100644 --- a/lotuspond/front/src/State.js +++ b/lotuspond/front/src/State.js @@ -22,7 +22,7 @@ class State extends React.Component { async componentDidMount() { const tipset = this.props.tipset || await this.props.client.call("Filecoin.ChainHead", []) - const actstate = await this.props.client.call('Filecoin.StateReadState', [this.props.actor, tipset.Cids]) + const actstate = await this.props.client.call('Filecoin.StateReadState', [this.props.addr, tipset.Cids]) const c = new CID(this.props.actor.Code['/']) const mh = multihash.decode(c.multihash) @@ -80,7 +80,7 @@ class PowerState extends React.Component { async componentDidMount() { const tipset = await this.props.client.call("Filecoin.ChainHead", []) // TODO: from props const actors = await this.props.client.call("Filecoin.StateListMiners", [tipset.Cids]) - const state = await this.props.client.call('Filecoin.StateReadState', [this.props.actor, tipset.Cids]) + const state = await this.props.client.call('Filecoin.StateReadState', [this.props.addr, tipset.Cids]) this.setState({actors, state}) } @@ -107,7 +107,7 @@ class MarketState extends React.Component { const tipset = await this.props.client.call("Filecoin.ChainHead", []) // TODO: from props const participants = await this.props.client.call("Filecoin.StateMarketParticipants", [tipset.Cids]) const deals = await this.props.client.call("Filecoin.StateMarketDeals", [tipset.Cids]) - const state = await this.props.client.call('Filecoin.StateReadState', [this.props.actor, tipset.Cids]) + const state = await this.props.client.call('Filecoin.StateReadState', [this.props.addr, tipset.Cids]) this.setState({participants, deals, nextDeal: state.State.NextDealID}) } @@ -153,7 +153,7 @@ class MinerState extends React.Component { async componentDidMount() { const tipset = await this.props.client.call("Filecoin.ChainHead", []) // TODO: from props - const state = await this.props.client.call('Filecoin.StateReadState', [this.props.actor, tipset.Cids]) + const state = await this.props.client.call('Filecoin.StateReadState', [this.props.addr, tipset.Cids]) const sectorSize = await this.props.client.call("Filecoin.StateMinerSectorSize", [this.props.addr, tipset.Cids]) const worker = await this.props.client.call("Filecoin.StateMinerWorker", [this.props.addr, tipset.Cids]) diff --git a/lotuspond/front/src/StorageNode.js b/lotuspond/front/src/StorageNode.js index bf85de642..9026cdb94 100644 --- a/lotuspond/front/src/StorageNode.js +++ b/lotuspond/front/src/StorageNode.js @@ -88,8 +88,7 @@ class StorageNode extends React.Component { const peers = await this.state.client.call("Filecoin.NetPeers", []) const actor = await this.state.client.call("Filecoin.ActorAddress", []) - const stActor = await this.props.fullConn.call('Filecoin.StateGetActor', [actor, null]) - const actorState = await this.props.fullConn.call('Filecoin.StateReadState', [stActor, null]) + const actorState = await this.props.fullConn.call('Filecoin.StateReadState', [actor, null]) this.setState({version: version, peers: peers.length, actor: actor, actorState: actorState}) await this.stagedList() @@ -98,7 +97,7 @@ class StorageNode extends React.Component { async stagedList() { let stagedList = await this.state.client.call("Filecoin.SectorsList", []) let staged = await stagedList - .map(sector => this.state.client.call("Filecoin.SectorsStatus", [sector])) + .map(sector => this.state.client.call("Filecoin.SectorsStatus", [sector, false])) .reduce(async (p, n) => [...await p, await n], Promise.resolve([])) let statusCounts = staged.reduce((p, n) => p.map((e, i) => e + (i === n.State ? 1 : 0) ), [0, 0, 0, 0, 0]) diff --git a/lotuspond/front/src/chain/send.js b/lotuspond/front/src/chain/send.js index 9011aca5e..a0fc89437 100644 --- a/lotuspond/front/src/chain/send.js +++ b/lotuspond/front/src/chain/send.js @@ -3,12 +3,6 @@ import { Buffer } from 'buffer' import { Tagged } from 'borc' async function pushMessage(client, from, inmsg) { - if(!inmsg.GasLimit) { - inmsg.GasLimit = "10000" - } - if(!inmsg.GasPrice) { - inmsg.GasPrice = "0" - } if(!inmsg.Params) { inmsg.Params = "oA==" // 0b101_00000: empty cbor map: {} } diff --git a/node/impl/full/state.go b/node/impl/full/state.go index 3b2953e02..ff8d9def1 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -378,22 +378,22 @@ func (a *StateAPI) StateReadState(ctx context.Context, actor address.Address, ts } state, err := a.stateForTs(ctx, ts) if err != nil { - return nil, err + return nil, xerrors.Errorf("getting state for tipset: %w", err) } act, err := state.GetActor(actor) if err != nil { - return nil, err + return nil, xerrors.Errorf("getting actor: %w", err) } blk, err := state.Store.(*cbor.BasicIpldStore).Blocks.Get(act.Head) if err != nil { - return nil, err + return nil, xerrors.Errorf("getting actor head: %w", err) } oif, err := vm.DumpActorState(act.Code, blk.RawData()) if err != nil { - return nil, err + return nil, xerrors.Errorf("dumping actor state (a:%s): %w", actor, err) } return &api.ActorState{ From 3fe8b1e73222cb83860b7a9cde1dd5aaa00d9d01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 7 Aug 2020 16:08:01 +0200 Subject: [PATCH 08/13] Better slashfilter logging --- chain/gen/slashfilter/slashfilter.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chain/gen/slashfilter/slashfilter.go b/chain/gen/slashfilter/slashfilter.go index ce1518e10..0d1940421 100644 --- a/chain/gen/slashfilter/slashfilter.go +++ b/chain/gen/slashfilter/slashfilter.go @@ -72,7 +72,7 @@ func (f *SlashFilter) MinedBlock(bh *types.BlockHeader, parentEpoch abi.ChainEpo } if !found { - return xerrors.Errorf("produced block would trigger 'parent-grinding fault' consensus fault; bh: %s, expected parent: %s", bh.Cid(), parent) + return xerrors.Errorf("produced block would trigger 'parent-grinding fault' consensus fault; miner: %s; bh: %s, expected parent: %s", bh.Miner, bh.Cid(), parent) } } } @@ -105,7 +105,7 @@ func checkFault(t ds.Datastore, key ds.Key, bh *types.BlockHeader, faultType str return err } - return xerrors.Errorf("produced block would trigger '%s' consensus fault; bh: %s, other: %s", faultType, bh.Cid(), other) + return xerrors.Errorf("produced block would trigger '%s' consensus fault; miner: %s; bh: %s, other: %s", faultType, bh.Miner, bh.Cid(), other) } return nil From 9b28be14cd4c940fc98dc41c43bdf821216460e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 7 Aug 2020 17:36:15 +0200 Subject: [PATCH 09/13] Betting logs --- miner/miner.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/miner/miner.go b/miner/miner.go index 102b49b0c..bf76e1067 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -396,7 +396,11 @@ func (m *Miner) mineOne(ctx context.Context, base *MiningBase) (*types.BlockMsg, tCreateBlock := build.Clock.Now() dur := tCreateBlock.Sub(start) - log.Infow("mined new block", "cid", b.Cid(), "height", b.Header.Height, "miner", b.Header.Miner, "parents", len(b.Header.Parents), "took", dur) + parentMiners := make([]address.Address, len(base.TipSet.Blocks())) + for i, header := range base.TipSet.Blocks() { + parentMiners[i] = header.Miner + } + log.Infow("mined new block", "cid", b.Cid(), "height", b.Header.Height, "miner", b.Header.Miner, "parents", parentMiners, "took", dur) if dur > time.Second*time.Duration(build.BlockDelaySecs) { log.Warnw("CAUTION: block production took longer than the block delay. Your computer may not be fast enough to keep up", "tMinerBaseInfo ", tMBI.Sub(start), From c8cf8f3ee174b6e38318e3321caa67ab802fa01a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 7 Aug 2020 17:51:03 +0200 Subject: [PATCH 10/13] Revert #2832 fully --- miner/miner.go | 55 +++++++++++++++----------------------------------- 1 file changed, 16 insertions(+), 39 deletions(-) diff --git a/miner/miner.go b/miner/miner.go index bf76e1067..dda8636c1 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -148,47 +148,24 @@ func (m *Miner) mine(ctx context.Context) { default: } - var base *MiningBase - var onDone func(bool, error) - var injectNulls abi.ChainEpoch + prebase, err := m.GetBestMiningCandidate(ctx) + if err != nil { + log.Errorf("failed to get best mining candidate: %s", err) + m.niceSleep(time.Second * 5) + continue + } - for { - prebase, err := m.GetBestMiningCandidate(ctx) - if err != nil { - log.Errorf("failed to get best mining candidate: %s", err) - m.niceSleep(time.Second * 5) - continue - } + // Wait until propagation delay period after block we plan to mine on + onDone, injectNulls, err := m.waitFunc(ctx, prebase.TipSet.MinTimestamp()) + if err != nil { + log.Error(err) + continue + } - if base != nil && base.TipSet.Height() == prebase.TipSet.Height() && base.NullRounds == prebase.NullRounds { - break - } - if base != nil { - onDone(false, nil) - } - - // TODO: need to change the orchestration here. the problem is that - // we are waiting *after* we enter this loop and selecta mining - // candidate, which is almost certain to change in multiminer - // tests. Instead, we should block before entering the loop, so - // that when the test 'MineOne' function is triggered, we pull our - // best mining candidate at that time. - - // Wait until propagation delay period after block we plan to mine on - onDone, injectNulls, err = m.waitFunc(ctx, prebase.TipSet.MinTimestamp()) - if err != nil { - log.Error(err) - continue - } - - /*// just wait for the beacon entry to become available before we select our final mining base - _, err = m.api.BeaconGetEntry(ctx, prebase.TipSet.Height()+prebase.NullRounds+1) - if err != nil { - log.Errorf("failed getting beacon entry: %s", err) - continue - }*/ - - base = prebase + base, err := m.GetBestMiningCandidate(ctx) + if err != nil { + log.Errorf("failed to get best mining candidate: %s", err) + continue } if base.TipSet.Equals(lastBase.TipSet) && lastBase.NullRounds == base.NullRounds { From 09b4971698e026da3b3e810dd8289a5770061ac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 7 Aug 2020 17:51:35 +0200 Subject: [PATCH 11/13] Less aggresive 2k devnet block time --- build/params_2k.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/params_2k.go b/build/params_2k.go index d22c6a6f8..12005f005 100644 --- a/build/params_2k.go +++ b/build/params_2k.go @@ -20,9 +20,9 @@ func init() { BuildType |= Build2k } -const BlockDelaySecs = uint64(2) +const BlockDelaySecs = uint64(4) -const PropagationDelaySecs = uint64(3) +const PropagationDelaySecs = uint64(1) // SlashablePowerDelay is the number of epochs after ElectionPeriodStart, after // which the miner is slashed From 3bac504fc3eed6ca0c7a27e5e024c9b329a2d8ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 7 Aug 2020 18:09:01 +0200 Subject: [PATCH 12/13] Use drand mainnet --- build/drand.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/drand.go b/build/drand.go index e24b802d6..4e29bdc74 100644 --- a/build/drand.go +++ b/build/drand.go @@ -2,7 +2,7 @@ package build import "github.com/filecoin-project/lotus/node/modules/dtypes" -var DrandNetwork = DrandTestnet +var DrandNetwork = DrandMainnet func DrandConfig() dtypes.DrandConfig { return DrandConfigs[DrandNetwork] From c62859e38b0f7bac05409fec497cd9bd801e841e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 7 Aug 2020 18:09:53 +0200 Subject: [PATCH 13/13] Unrevert #2832 with fixed code --- miner/miner.go | 56 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/miner/miner.go b/miner/miner.go index dda8636c1..d5a656e23 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -148,24 +148,48 @@ func (m *Miner) mine(ctx context.Context) { default: } - prebase, err := m.GetBestMiningCandidate(ctx) - if err != nil { - log.Errorf("failed to get best mining candidate: %s", err) - m.niceSleep(time.Second * 5) - continue - } + var base *MiningBase + var onDone func(bool, error) + var injectNulls abi.ChainEpoch - // Wait until propagation delay period after block we plan to mine on - onDone, injectNulls, err := m.waitFunc(ctx, prebase.TipSet.MinTimestamp()) - if err != nil { - log.Error(err) - continue - } + for { + prebase, err := m.GetBestMiningCandidate(ctx) + if err != nil { + log.Errorf("failed to get best mining candidate: %s", err) + m.niceSleep(time.Second * 5) + continue + } - base, err := m.GetBestMiningCandidate(ctx) - if err != nil { - log.Errorf("failed to get best mining candidate: %s", err) - continue + if base != nil && base.TipSet.Height() == prebase.TipSet.Height() && base.NullRounds == prebase.NullRounds { + base = prebase + break + } + if base != nil { + onDone(false, nil) + } + + // TODO: need to change the orchestration here. the problem is that + // we are waiting *after* we enter this loop and selecta mining + // candidate, which is almost certain to change in multiminer + // tests. Instead, we should block before entering the loop, so + // that when the test 'MineOne' function is triggered, we pull our + // best mining candidate at that time. + + // Wait until propagation delay period after block we plan to mine on + onDone, injectNulls, err = m.waitFunc(ctx, prebase.TipSet.MinTimestamp()) + if err != nil { + log.Error(err) + continue + } + + // just wait for the beacon entry to become available before we select our final mining base + _, err = m.api.BeaconGetEntry(ctx, prebase.TipSet.Height()+prebase.NullRounds+1) + if err != nil { + log.Errorf("failed getting beacon entry: %s", err) + continue + } + + base = prebase } if base.TipSet.Equals(lastBase.TipSet) && lastBase.NullRounds == base.NullRounds {