From 6d766ab241b204cf4868fad0b5021ec3f1671ad0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 28 Oct 2019 19:22:40 +0100 Subject: [PATCH] Set e=3 --- build/params.go | 2 +- chain/gen/gen.go | 2 +- chain/types/blockheader.go | 5 ++++- chain/vm/vm.go | 5 +++++ lotuspond/front/src/BlockLink.js | 2 +- lotuspond/front/src/ChainExplorer.js | 2 +- lotuspond/front/src/Consensus.js | 2 +- 7 files changed, 14 insertions(+), 6 deletions(-) diff --git a/build/params.go b/build/params.go index 00808dbe4..0e19e4972 100644 --- a/build/params.go +++ b/build/params.go @@ -46,7 +46,7 @@ const AllowableClockDrift = BlockDelay * 2 const ForkLengthThreshold = 100 // Blocks (e) -const BlocksPerEpoch = 1 +const BlocksPerEpoch = 3 // Blocks const Finality = 500 diff --git a/chain/gen/gen.go b/chain/gen/gen.go index 91d7947c4..b38f2c0df 100644 --- a/chain/gen/gen.go +++ b/chain/gen/gen.go @@ -419,7 +419,7 @@ func IsRoundWinner(ctx context.Context, ts *types.TipSet, ticks []*types.Ticket, return false, nil, xerrors.Errorf("failed to check power: %w", err) } - return types.PowerCmp(vrfout, types.BigMul(pow.MinerPower, types.NewInt(build.BlocksPerEpoch)), pow.TotalPower), vrfout, nil + return types.PowerCmp(vrfout, pow.MinerPower, pow.TotalPower), vrfout, nil } type SignFunc func(context.Context, address.Address, []byte) (*types.Signature, error) diff --git a/chain/types/blockheader.go b/chain/types/blockheader.go index a82bf37a2..6109df28f 100644 --- a/chain/types/blockheader.go +++ b/chain/types/blockheader.go @@ -12,6 +12,7 @@ import ( "go.opencensus.io/trace" xerrors "golang.org/x/xerrors" + "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/address" ) @@ -159,6 +160,8 @@ func CidArrsEqual(a, b []cid.Cid) bool { return true } +var blocksPerEpoch = NewInt(build.BlocksPerEpoch) + func PowerCmp(eproof ElectionProof, mpow, totpow BigInt) bool { /* @@ -171,7 +174,7 @@ func PowerCmp(eproof ElectionProof, mpow, totpow BigInt) bool { // 2^256 rden := BigInt{big.NewInt(0).Exp(big.NewInt(2), big.NewInt(256), nil)} - top := BigMul(rden, mpow) + top := BigMul(BigMul(rden, mpow), blocksPerEpoch) out := BigDiv(top, totpow) hp := BigFromBytes(h[:]) diff --git a/chain/vm/vm.go b/chain/vm/vm.go index 1cfcab905..8b702c48b 100644 --- a/chain/vm/vm.go +++ b/chain/vm/vm.go @@ -488,6 +488,9 @@ func (vm *VM) ApplyMessage(ctx context.Context, msg *types.Message) (*ApplyRet, return nil, xerrors.Errorf("getting block miner actor (%s) failed: %w", vm.blockMiner, err) } + + // TODO: support multiple blocks in a tipset + // TODO: actually wire this up (miner is undef for now) gasReward := types.BigMul(msg.GasPrice, gasUsed) if err := Transfer(gasHolder, miner, gasReward); err != nil { return nil, xerrors.Errorf("failed to give miner gas reward: %w", err) @@ -630,6 +633,7 @@ func depositFunds(act *types.Actor, amt types.BigInt) { } var miningRewardTotal = types.FromFil(build.MiningRewardTotal) +var blocksPerEpoch = types.NewInt(build.BlocksPerEpoch) // MiningReward returns correct mining reward // coffer is amount of FIL in NetworkAddress @@ -637,5 +641,6 @@ func MiningReward(remainingReward types.BigInt) types.BigInt { ci := big.NewInt(0).Set(remainingReward.Int) res := ci.Mul(ci, build.InitialReward) res = res.Div(res, miningRewardTotal.Int) + res = res.Div(res, blocksPerEpoch.Int) return types.BigInt{res} } diff --git a/lotuspond/front/src/BlockLink.js b/lotuspond/front/src/BlockLink.js index 1faac124c..bfdbd5ea9 100644 --- a/lotuspond/front/src/BlockLink.js +++ b/lotuspond/front/src/BlockLink.js @@ -12,7 +12,7 @@ export class BlockLinks extends React.Component { block = this.props.blocks[k] } - return + return }) } } diff --git a/lotuspond/front/src/ChainExplorer.js b/lotuspond/front/src/ChainExplorer.js index 1f8f619c0..8957cb3d0 100644 --- a/lotuspond/front/src/ChainExplorer.js +++ b/lotuspond/front/src/ChainExplorer.js @@ -169,7 +169,7 @@ class ChainExplorer extends React.Component { return
@{h} {info}
})} - return ( + return ( {content} ) } diff --git a/lotuspond/front/src/Consensus.js b/lotuspond/front/src/Consensus.js index 86b1362a4..14b4dd6e2 100644 --- a/lotuspond/front/src/Consensus.js +++ b/lotuspond/front/src/Consensus.js @@ -5,7 +5,7 @@ import Window from "./Window"; function styleForHDiff(max, act) { switch (max - act) { case 0: - return {background: '#00aa00'} + return {background: '#004400'} case 1: return {background: '#aaaa00'} default: