This commit is contained in:
Łukasz Magiera 2019-10-28 19:22:40 +01:00
parent ac98c8f451
commit 6d766ab241
7 changed files with 14 additions and 6 deletions

View File

@ -46,7 +46,7 @@ const AllowableClockDrift = BlockDelay * 2
const ForkLengthThreshold = 100
// Blocks (e)
const BlocksPerEpoch = 1
const BlocksPerEpoch = 3
// Blocks
const Finality = 500

View File

@ -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)

View File

@ -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[:])

View File

@ -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}
}

View File

@ -12,7 +12,7 @@ export class BlockLinks extends React.Component {
block = this.props.blocks[k]
}
return <BlockLink key={c + '-' + k} block={block} conn={this.props.conn} cid={c} mountWindow={this.props.mountWindow}/>
return <span><BlockLink key={c + '-' + k} block={block} conn={this.props.conn} cid={c} mountWindow={this.props.mountWindow}/> </span>
})
}
}

View File

@ -169,7 +169,7 @@ class ChainExplorer extends React.Component {
return <div key={row} className={className}>@{h} {info}</div>
})}</div>
return (<Window onClose={this.props.onClose} title={`Chain Explorer ${this.state.follow ? '(Following)' : ''}`}>
return (<Window initialSize={{width: 800}} onClose={this.props.onClose} title={`Chain Explorer ${this.state.follow ? '(Following)' : ''}`}>
{content}
</Window>)
}

View File

@ -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: